From 8d42fc40bc1b31efa7913198e23f39ac46532dc7 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 17 Mar 2025 09:10:58 -0700 Subject: [PATCH] iOS: Fixes Switch component incorrectly renders as toggled on even though value prop is hardcoded to false (#50049) Summary: Fixes https://github.com/facebook/react-native/issues/50026 ## Changelog: [IOS] [FIXED] - [Fabric] iOS: Fixes Switch component incorrectly renders as toggled on even though value prop is hardcoded to false Pull Request resolved: https://github.com/facebook/react-native/pull/50049 Test Plan: Repro please see https://github.com/facebook/react-native/issues/50026. Reviewed By: javache Differential Revision: D71307864 Pulled By: cipolleschi fbshipit-source-id: 57238296842229cf2f23a3f44134f43e27b54609 --- .../Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm index c3d44953ef3..c4e36804615 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm @@ -60,7 +60,7 @@ using namespace facebook::react; const auto &newSwitchProps = static_cast(*props); // `value` - if (oldSwitchProps.value != newSwitchProps.value) { + if (!_isInitialValueSet || oldSwitchProps.value != newSwitchProps.value) { BOOL shouldAnimate = _isInitialValueSet == YES; [_switchView setOn:newSwitchProps.value animated:shouldAnimate]; }