Skip to content

Commit 56ecc7d

Browse files
authored
Fix synchronous props updates on iOS below RN 0.81 (#8427)
## Summary Currently, animating props synchronously is broken on React Native 0.80 or older because `schedulerDidSynchronouslyUpdateViewOnUIThread:props:` method that we're using was added facebook/react-native#51470 in which was released in React Native 0.81. In #8248, @patrycjakalinska added ifdefs to disable this flow on `react-native-macos` but it is not a problem with macOS itself but rather with the version of React Native (currently, `macos-example` runs on 0.79). This PR fixes animating props synchronously on iOS on React Native 0.80 and older. ## Test plan
1 parent eece0de commit 56ecc7d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/react-native-reanimated/apple/reanimated/apple/REANodesManager.mm

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#import <React/RCTMountingManager.h>
99
#import <React/RCTUtils.h>
1010

11+
#if REACT_NATIVE_MINOR_VERSION < 81
12+
#import <React/RCTFollyConvert.h>
13+
#endif
14+
15+
using namespace facebook::react;
16+
1117
@implementation REANodesManager {
1218
READisplayLink *_displayLink;
1319
NSMutableArray<REAOnAnimationCallback> *_onAnimationCallbacks;
@@ -157,19 +163,22 @@ - (void)maybeFlushUIUpdatesQueue
157163

158164
- (void)synchronouslyUpdateUIProps:(ReactTag)viewTag props:(const folly::dynamic &)props
159165
{
160-
#if !TARGET_OS_OSX
161166
RCTAssertMainQueue();
162167

163168
RCTSurfacePresenter *surfacePresenter = self.surfacePresenter;
164169
RCTComponentViewRegistry *componentViewRegistry = surfacePresenter.mountingManager.componentViewRegistry;
165-
UIView<RCTComponentViewProtocol> *componentView = [componentViewRegistry findComponentViewWithTag:viewTag];
170+
REAUIView<RCTComponentViewProtocol> *componentView =
171+
[componentViewRegistry findComponentViewWithTag:static_cast<Tag>(viewTag)];
166172
NSSet<NSString *> *propKeysManagedByAnimated = [componentView propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN];
173+
#if REACT_NATIVE_MINOR_VERSION >= 81
167174
[surfacePresenter schedulerDidSynchronouslyUpdateViewOnUIThread:viewTag props:props];
175+
#else
176+
[surfacePresenter synchronouslyUpdateViewOnUIThread:@(viewTag) props:convertFollyDynamicToId(props)];
177+
#endif
168178
[componentView setPropKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN:propKeysManagedByAnimated];
169179
// `synchronouslyUpdateViewOnUIThread` does not flush props like `backgroundColor` etc.
170180
// so that's why we need to call `finalizeUpdates` here.
171181
[componentView finalizeUpdates:RNComponentViewUpdateMask{}];
172-
#endif // !TARGET_OS_OSX
173182
}
174183

175184
@end

0 commit comments

Comments
 (0)