Commit ae91e3a
authored
[iOS] Fix buttons crash when unmounting children (#4065)
## Description
`buttonView` is `UIControl`, which unlike `RCTViewComponentView` does
strict checks for view index when unmounting children.
Fixes #4062
## Test plan
<details>
<summary>Tested on example from #4062</summary>
```tsx
import { useState } from 'react';
import { Pressable, Text, View } from 'react-native';
import {
Clickable,
GestureHandlerRootView,
} from 'react-native-gesture-handler';
export default function App() {
const [children, setChildren] = useState<React.ReactNode[]>([]);
return (
<GestureHandlerRootView
style={[
{ flex: 1, alignItems: 'center', justifyContent: 'center' },
{ marginTop: 25 },
]}>
<Clickable>
<Text>Clickable</Text>
{children.map((child, index) => (
<View key={index}>{child}</View>
))}
</Clickable>
<Pressable
onPress={() =>
setChildren([
...children,
<Text key={children.length}>New child</Text>,
])
}>
<Text>Add child to Clickable</Text>
</Pressable>
<Pressable onPress={() => setChildren(children.slice(0, -1))}>
<Text>Remove child from Clickable</Text>
</Pressable>
</GestureHandlerRootView>
);
}
```
</details>1 parent dac49b0 commit ae91e3a
1 file changed
Lines changed: 5 additions & 2 deletions
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
76 | 77 | | |
77 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
0 commit comments