react-native-hold-menu
react-native-hold-menu copied to clipboard
Error: Value is undefined, expected an Object
Describe the bug
When pressing an option in the menu with an onPress
I get this error:
Error: Value is undefined, expected an Object
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue
This is my code:
<HoldItem
items={[
{ text: "Test", onPress: () => {}, isTitle: false },
{ text: "Reply", onPress: () => console.log("hi") },
{ text: "A (no onPress)", isDestructive: true },
]}
containerStyles={{ width: "100%", alignItems: "center" }}
>
<HomePageButton
text="test"
onPress={() => null}
style={{ alignSelf: "center" }}
/>
</HoldItem>
To Reproduce Steps to reproduce the behavior:
- Install
react-native-hold-menu
- Create a menu with an item with
onPress: () => {}
Expected behavior
I of course expect it to not error and just run the onPress
function.
Actual behavior
When I press an item that has an onPress
function, I get an error. If it doesn't have the onPress
function, I don't.
https://user-images.githubusercontent.com/31771656/118395775-744e7280-b64c-11eb-8296-d973069a2391.mov
Screenshots
Error on my phone:
Package versions
- React: 16.13.1
- React Native: 0.64
- React Native Reanimated: 2.1.0
- React Native Hold Menu: 0.0.8
- Expo: 41
Additional context
This also happens on android.
I'm getting the same thing on iOS also.
I've tried this is two different Expo 41 projects with the same results. The only difference is that I am using React native hold menu v0.1.0.
My project did work with rn hold menu 0.0.8 BUT with Expo 40 which had the RC for Reanimated. I'm wondering if this is an issue with reanimated v2.1.0?
Hi guys, this was an important issue that SW Mansion team worked on it and solved in Reanimated v2.1.0 actually. But some how it still does not work on Expo projects. I told them and not sure the team will work on it.
For now, you should use React Native Hold Menu v0.1.0 and it will work on bare RN workflow. Expo will sill throw this error and this issue is about Reanimated.
So as I understood, both of your examples are in Expo project. I already know this issue. If there is some other issue let me know.
Thanks for the reply. Yes, I'm using Expo managed workflow (SDK 41). I'm not sure I'm ready to go to the bare workflow yet, but I really like this library and find it very useful!
Thanks
Thanks @markmccoid. I was so excited and still excited about this repo but unfortunately it needs some time and improvements/fixes on Reanimated, Expo and itself to be used in production. Will continue to work on it 🔥
I found Expo 41 ships reanimated v2.0.1 native modules, but v2.1.0 on JS side expo/expo@d783eeb
Not sure why, maybe because the reanimated release was a little late during expo 41 release, so they don't took the risk to ship with it. Anyway I don't think there will be a solution until expo 42 in managed workflow…
Is this issue still present with Expo SDK 43?
having the same issue with react-native-reanimated 3.x