Skip to content

Commit

Permalink
fix: warning when a non-boolean values was used to set checked prop…
Browse files Browse the repository at this point in the history
… of a SwitchInput component (#3276)

fix: warning when a non-boolean values was used to set`checked` prop of SwitchInput component

The problem was that in the useEffect hook the plain value was used without validation like in useState
  • Loading branch information
rhumbertgz authored Sep 27, 2024
1 parent da0a15e commit 99cb8c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ui/src/ui-component/switch/Switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const SwitchInput = ({ label, value, onChange, disabled = false }) => {
const [myValue, setMyValue] = useState(value !== undefined ? !!value : false)

useEffect(() => {
setMyValue(value)
setMyValue(value !== undefined ? !!value : false)
}, [value])

return (
Expand Down

0 comments on commit 99cb8c3

Please sign in to comment.