We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d92ecda commit 71a588bCopy full SHA for 71a588b
Libraries/Components/Switch/Switch.js
@@ -165,12 +165,13 @@ const SwitchWithForwardedRef: React.AbstractComponent<
165
setNative({value: event.nativeEvent.value});
166
};
167
168
- React.useEffect(() => {
+ React.useLayoutEffect(() => {
169
// This is necessary in case native updates the switch and JS decides
170
// that the update should be ignored and we should stick with the value
171
// that we have in JS.
172
const jsValue = value === true;
173
- const shouldUpdateNativeSwitch = native.value !== jsValue;
+ const shouldUpdateNativeSwitch =
174
+ native.value != null && native.value !== jsValue;
175
if (
176
shouldUpdateNativeSwitch &&
177
nativeSwitchRef.current?.setNativeProps != null
0 commit comments