From 4bd1426f0fe69a394d7d06e606ad73229cebd91a Mon Sep 17 00:00:00 2001 From: Rodriguez Avila Humberto Date: Fri, 27 Sep 2024 10:52:46 +0200 Subject: [PATCH] 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 --- packages/ui/src/ui-component/switch/Switch.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/ui-component/switch/Switch.jsx b/packages/ui/src/ui-component/switch/Switch.jsx index e2d2dd78eee..ad35fda1046 100644 --- a/packages/ui/src/ui-component/switch/Switch.jsx +++ b/packages/ui/src/ui-component/switch/Switch.jsx @@ -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 (