mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Native Animations - Fix edge case with restore default values
Summary: There was an edge case where sometimes a view could be added and removed in the same batch so this caused issues because we ran `disconnectAnimatedNodeFromView` before `connectAnimatedNodeToView`. This separates restoring default values from `disconnectAnimatedNodeFromView` so we can run only `restoreDefaultValues` on the pre-operations queue and just do nothing in case the view doesn't exist (it is fine because we know it will be removed immediately). **Test plan** Tested that native animations still work properly in RNTester and tested that the edge case crash was fixed. Closes https://github.com/facebook/react-native/pull/14114 Differential Revision: D5128989 Pulled By: javache fbshipit-source-id: 9f47a2d3aafeb06d8ed1a4dd1800b8af225edb7d
This commit is contained in:
committed by
Facebook Github Bot
parent
46104a1f78
commit
fc45471af2
@@ -135,6 +135,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)restoreDefaultValues:(nonnull NSNumber *)nodeTag
|
||||
{
|
||||
RCTAnimatedNode *node = _animationNodes[nodeTag];
|
||||
// Restoring default values needs to happen before UIManager operations so it is
|
||||
// possible the node hasn't been created yet if it is being connected and
|
||||
// disconnected in the same batch. In that case we don't need to restore
|
||||
// default values since it will never actually update the view.
|
||||
if (node == nil) {
|
||||
return;
|
||||
}
|
||||
if (![node isKindOfClass:[RCTPropsAnimatedNode class]]) {
|
||||
RCTLogError(@"Not a props node.");
|
||||
}
|
||||
[(RCTPropsAnimatedNode *)node restoreDefaultValues];
|
||||
}
|
||||
|
||||
- (void)dropAnimatedNode:(nonnull NSNumber *)tag
|
||||
{
|
||||
RCTAnimatedNode *node = _animationNodes[tag];
|
||||
|
||||
Reference in New Issue
Block a user