Skip to content

Press outside of ActionSheet crashs the application #2714

Open
@edersonmberti

Description

@edersonmberti

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

  1. Use the ActionSheet component
  2. Show the ActionSheet
  3. Press outside of the ActionSheet component
  4. 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:
simulator_screenshot_02996209-69E9-4AC4-A31F-8A41DB30C732

Environment

  • React Native version: 0.68.6
  • React Native UI Lib version: 6.31.0

Affected platforms

  • Android
  • iOS
  • Web

Metadata

Metadata

Assignees

Labels

buga bug in one of the components

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions