Skip to content

Commit 99cb8c3

Browse files
authored
fix: warning when a non-boolean values was used to set checked prop 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
1 parent da0a15e commit 99cb8c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/ui/src/ui-component/switch/Switch.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const SwitchInput = ({ label, value, onChange, disabled = false }) => {
66
const [myValue, setMyValue] = useState(value !== undefined ? !!value : false)
77

88
useEffect(() => {
9-
setMyValue(value)
9+
setMyValue(value !== undefined ? !!value : false)
1010
}, [value])
1111

1212
return (

0 commit comments

Comments
 (0)