Press outside of ActionSheet crashs the application
Open
@nitzanyiz is already working on this.
Since Oct 17, 2023.
bug
- Dominant language
- TypeScript
- Stars
- 7.2k
- Forks
- 748
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 1
Description
Description
Used the ActionSheet component, when the component is visible and the user press anywhere outside the component the application crashes.
Somehow when this happens the option index sent to the onOptionPress function is always the same as the size of the options array.
options.length = 3, the value sent is 3.
Related to
- Components
- Demo
- Docs
- Typings
Steps to reproduce
- Use the ActionSheet component
- Show the ActionSheet
- Press outside of the ActionSheet component
- See the error
Expected behavior
Hide the ActionSheet.
Actual behavior
Crash the application.
More Info
Code snippet
Current code:
onOptionPress(optionIndex: number) {
this.props.options?.[optionIndex].onPress?.();
this.props.onDismiss?.();
}
Fix:
onOptionPress(optionIndex: number) {
this.props.options?.[optionIndex]?.onPress?.();
this.props.onDismiss?.();
}
Screenshots/Video
Error:
Environment
- React Native version: 0.68.6
- React Native UI Lib version: 6.31.0
Affected platforms
- Android
- iOS
- Web
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.