mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
fix(iOS): fix animating Switch component value change (#46173)
Summary: This PR fixes animating controlled `Switch` component when it's initial value is set to `false` When initial value was set to `false`, `_isInitialValueSet` flag wasn't changed to `YES`, because `oldSwitchProps.value` &`newSwitchProps.value` were equal, which resulted in controlled `Switch` component being updated without animation on first value change This PR fixes it by moving setting `_isInitialValueSet` flag to the end of `updateProps` method ## Changelog: [IOS] [FIXED] - Fix animating Switch component value change in Fabric Pull Request resolved: https://github.com/facebook/react-native/pull/46173 Test Plan: 1. Open `Switch` example in `RNTester` 2. In `Change events can be detected` section press switch that is `off` by default 3. Switch under it should change with animation Reviewed By: javache Differential Revision: D62377771 Pulled By: cipolleschi fbshipit-source-id: 0213287c935db79a199b086ebb36a6979df03913
This commit is contained in:
1 parent
95af340aac
commit
84f2d25124
1 file changed
+2
-1
+2
-1
@@ -63,7 +63,6 @@ using namespace facebook::react;
|
||||
if (oldSwitchProps.value != newSwitchProps.value) {
|
||||
BOOL shouldAnimate = _isInitialValueSet == YES;
|
||||
[_switchView setOn:newSwitchProps.value animated:shouldAnimate];
|
||||
_isInitialValueSet = YES;
|
||||
}
|
||||
|
||||
// `disabled`
|
||||
@@ -86,6 +85,8 @@ using namespace facebook::react;
|
||||
_switchView.thumbTintColor = RCTUIColorFromSharedColor(newSwitchProps.thumbTintColor);
|
||||
}
|
||||
|
||||
_isInitialValueSet = YES;
|
||||
|
||||
[super updateProps:props oldProps:oldProps];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user