-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of layout animations coinciding with view flattening (#6460
) ## Summary This PR fixes the way a reparenting of views is handled in Layout Animations. It can so happen that a view is being removed and in the same transaction its parent is being moved (due to view flattening). The current implementation in this scenario would move the parent correctly and remove the `MutationNode` from our registry. However, the pointer to this `MutationNode` was still stored as a parent by the child node. This would lead to us trying to remove the previously moved node when the child animation ended. This would lead to a crash, since we tried to remove the view from its old parent. ## Test plan Check the `[LA] View flattening` example, and other examples for regressions.
- Loading branch information
1 parent
a3de2b2
commit 0744e73
Showing
4 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
apps/common-app/src/examples/LayoutAnimations/ViewFlattening.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { StyleSheet, View, Button } from 'react-native'; | ||
import Animated, { FadeOut } from 'react-native-reanimated'; | ||
|
||
import React from 'react'; | ||
|
||
export default function ViewFlatteningExample() { | ||
const [visible, setVisible] = React.useState(true); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Button title="Toggle" onPress={() => setVisible(!visible)} /> | ||
<View style={styles.purpleBox} collapsable={!visible}> | ||
<View style={styles.redBox} collapsable={visible}> | ||
<View style={styles.greenBox} collapsable={false}> | ||
{visible && ( | ||
<Animated.View | ||
style={styles.blueBox} | ||
exiting={FadeOut.duration(2000)} | ||
/> | ||
)} | ||
</View> | ||
</View> | ||
<View style={styles.redBox} collapsable={!visible}> | ||
<View style={styles.greenBox} collapsable={false}> | ||
{visible && ( | ||
<Animated.View | ||
style={styles.blueBox} | ||
exiting={FadeOut.duration(2000)} | ||
/> | ||
)} | ||
</View> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
purpleBox: { | ||
width: 200, | ||
height: 200, | ||
backgroundColor: 'purple', | ||
}, | ||
redBox: { | ||
width: 100, | ||
height: 100, | ||
backgroundColor: 'red', | ||
}, | ||
greenBox: { | ||
width: 50, | ||
height: 50, | ||
backgroundColor: 'green', | ||
}, | ||
blueBox: { | ||
width: 25, | ||
height: 25, | ||
backgroundColor: 'blue', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters