Skip to content

Commit

Permalink
Don't update view tag when null (#6353)
Browse files Browse the repository at this point in the history
## Summary

`setLocalRef` may be called with `null` being passed as the argument.
This is handled by the conditional in the logic related to layout
animations but not when updating the component view tag. There may be
cases where component view tag will become null and will be passed to
[`removePropsFromRegistry`](https://github.com/software-mansion/react-native-reanimated/blob/158602bd4137ae70aceaaf43e3f2b75b47da04a5/packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx#L253),
which will then crash on the native side as it assumes it will receive
an array of numbers.

Assuming this is the correct way to handle this (is it possible that
assigning null to view tag is expected here?), then the code may be
changed slightly not to repeat the same check and do an early return.
Let me know if you prefer that.

## Test plan

Just trust me

(I don't have any other reproduction than the Expensify App on the 0.74
upgrade branch (with strict mode enabled, without it everything works)
😞)
  • Loading branch information
j-piasecki authored Aug 13, 2024
1 parent a96d787 commit f8f7777
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,11 @@ export function createAnimatedComponent(

const tag = findNodeHandle(ref as Component);

this._componentViewTag = tag as number;
// callback refs are executed twice - when the component mounts with ref,
// and with null when it unmounts
if (tag !== null) {
this._componentViewTag = tag;
}

const { layout, entering, exiting, sharedTransitionTag } = this.props;
if (
Expand Down

0 comments on commit f8f7777

Please sign in to comment.