ActionSheetProvider in place, class actionSheet works, hook actionSheet does not work.
See original GitHub issueI have an ActionSheetProvider that works and is in App.tsx. In many class component the actionSheet works, however in a functional component using the hook it doesn’t.
I was trying to make sure I followed correctly the docs.
App.tsx
In my functional component:
const { showActionSheetWithOptions } = useActionSheet();
const openActionSheet = (document: {}) =>
showActionSheetWithOptions(
{
options,
cancelButtonIndex,
},
(buttonIndex) => {
switch (buttonIndex) {
case 0:
pickImageAsync(
onDocumentPicker,
document != null
? document
: { document: { documentType: "foto" } }
);
return;
case 1:
takePictureAsync(
onDocumentPicker,
document != null
? {
document,
}
: null
);
return;
case 2:
chooseFileAsync(
onDocumentPicker,
document != null
? {
document,
}
: null
);
return;
default:
}
}
);
The action gets fired but nothing happens. Any help would be appreciated. Since the examples in the doc explain how to use the hook in app.tsx I’m not sure if the hook should be used directly in a functional component or if it is an alternative to the <ActionSheetProvider /> HOC
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
How to use react-native-action-sheet with hooks
I'm already using the class components version without any problem but I'd like to switch to functional. React version is 16.9.0. This is...
Read more >exponentjs - Bountysource
Hi,. I would like to open this issue because I had some trouble with my app. ActionSheet.showActionSheetWithOptions( { options, } ...
Read more >ActionSheet provider and hook in React Native - YouTube
In this video I'll show how we can create an actionsheet provider and react hook using the native base actionsheet. This will save...
Read more >Ionic 4 Action Sheet Tutorial - YouTube
By the end of this tutorial, the ionic 4 action sheet will be no match for you! Please LIKE and SUB if this...
Read more >A cross-platform ActionSheet for React Native - Morioh
ActionSheet is a cross-platform React Native component that uses the native UIActionSheet on iOS and a JS implementation on Android.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
unfortunately no, I didn’t. I’m sure there is an explanation, however I am forced to embed the component inside the tag to make it work on the functional component.
I encountered a similar problem, and eventually I noticed that the problem is related to the “react-native-navigation” library I used. If you use any navigation libraries, then just wrap top-level component with ActionSheetProvider may not work.
For “react-native-navigation”, I have to wrap each component separately using Navigation.registerComponent()