Controlled Checkbox
How to use React Checkbox Pro in controlled mode
Controlled Checkbox
Learn how to use React Checkbox Pro in controlled mode, where you manage the checkbox state in your React component.
Example
Current state: Unchecked
Usage
Basic Controlled Mode
With Custom Handler
Best Practices
-
Use controlled mode when you need to:
- Sync checkbox state with other components
- Validate state changes
- Perform side effects on state changes
-
Always provide both
checked
andonChange
props -
Consider using
useCallback
for performance optimization: -
Avoid unnecessary re-renders by keeping state management close to where it's needed