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
This commit is contained in:
Humberto Rodríguez A. 2024-09-27 14:50:05 +02:00 committed by GitHub
parent da0a15eee1
commit 99cb8c32cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -6,7 +6,7 @@ export const SwitchInput = ({ label, value, onChange, disabled = false }) => {
const [myValue, setMyValue] = useState(value !== undefined ? !!value : false) const [myValue, setMyValue] = useState(value !== undefined ? !!value : false)
useEffect(() => { useEffect(() => {
setMyValue(value) setMyValue(value !== undefined ? !!value : false)
}, [value]) }, [value])
return ( return (