-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Update checkbox component to functional component #3169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update checkbox component to functional component #3169
Conversation
Signed-off-by: Indranil Halder <[email protected]>
Signed-off-by: Indranil Halder <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR converts a class-based React component to a functional component using modern React patterns. The main goal is to modernize the Checkbox component by leveraging React hooks instead of class-based state management.
- Replaces class component with functional component using React FC type
- Converts class state to useState hook for focus management
- Updates event handlers to use functional component patterns
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const StyledRadiuInput = styled.label.withConfig({shouldForwardProp})<StyledSwitchInputProps>` | ||
| const StyledRadioInput = styled.label.withConfig({shouldForwardProp})<StyledSwitchInputProps>` | ||
| ${props => (props.secondary ? props.theme.secondaryRadio : props.theme.inputRadio)}; | ||
| background-color: 'red'; |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The background-color CSS property value should not be wrapped in quotes. This will be interpreted as a string literal rather than a color value.
| background-color: 'red'; | |
| background-color: red; |
| onChange = noop, | ||
| onFocus = noop | ||
| }) => { | ||
| const [, setFocused] = useState(false); |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The focused state is being tracked but never used (notice the underscore destructuring). If focus state tracking is not needed, this useState and its related handlers can be removed to simplify the component.
| ...pick({checked, disabled, id, onChange, value, secondary}, [ | ||
| 'checked', | ||
| 'disabled', | ||
| 'id', | ||
| 'onChange', | ||
| 'value', | ||
| 'secondary' | ||
| ]), |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pick operation is redundant since you're extracting the same properties that are already destructured from props. You can directly use {checked, disabled, id, onChange, value, secondary} instead.
Updated the checkbox component to a functional component.