GSTJ / react-native-magic-modal

🦄 A modal library that can be called imperatively from anywhere!
https://github.com/GSTJ/react-native-magic-modal
MIT License
204 stars 8 forks source link

WARN [react-native-gesture-handler] None of the callbacks in the gesture are worklets. #88

Closed outaTiME closed 2 months ago

outaTiME commented 3 months ago

Describe the bug I am getting the following message when I try to open a modal from within a useEffect, is this allowed?

WARN [react-native-gesture-handler] None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.

I'm using Expo 51 with "react-native-gesture-handler": "^2.17.1" and "react-native-reanimated": "^3.12.1".

Here are some code snippets:

// App.js
<Provider store={store}>
  <PersistGate loading={null} persistor={persistor}>
    <GestureHandlerRootView>
      <SafeAreaProvider>
        <ThemedApp />
      </SafeAreaProvider>
      <MagicModalPortal />
    </GestureHandlerRootView>
  </PersistGate>
</Provider>

// ThemedApp.js
const QuickModal = ({ text }) => {
  return (
    <View>
      <Text>Hey! I'm going to be closed imperatively</Text>
    </View>
  );
};
// ...
React.useEffect(() => {
  magicModal.show(() => <QuickModal />, {
    onBackButtonPress: () => {},
    onBackdropPress: () => {},
    swipeDirection: undefined,
  });
}, []);
TarunBardawa commented 3 months ago

+1

GSTJ commented 2 months ago

While I could not reproduce the warnings, I just merged a PR marking the functions as workouts.

This should close the issue. Let me know if it still happens on the latest version, and we can reopen it.