dai-shi / use-context-selector

React useContextSelector hook in userland
https://www.npmjs.com/package/use-context-selector
MIT License
2.68k stars 61 forks source link

React Native: Crash occurs when using `createContext` and `MyContext.Provider` after updating to react-native v0.72 or later #110

Closed VictorPrata closed 8 months ago

VictorPrata commented 1 year ago

image

After upgrade to react-native 0.72 my app started to crash when I access the screen with the createContext. Apparently error occurs when I call <MyContext.Provider ...

Error: Not implemented.

This error is located at: in Unknown (created by TestContextProvider) in TestContextProvider (created by SearchResultScreen) in RCTView (created by View) in View (created by BaseScreenTemplate) in BaseScreenTemplate (created by HeadedScreenTemplate) in HeadedScreenTemplate (created by SearchResultsHeadedTemplate) in SearchResultsHeadedTemplate (created by SearchResultScreen) in SearchResultScreen (created by SceneView) in StaticContainer in EnsureSingleNavigator (created by SceneView) in SceneView (created by CardContainer) in RCTView (created by View) in View (created by CardContainer) in RCTView (created by View) in View (created by CardContainer) in RCTView (created by View) in View in CardSheet (created by Card) in RCTView (created by View) in View in Unknown (created by PanGestureHandler) in PanGestureHandler (created by PanGestureHandler) in PanGestureHandler (created by Card) in RCTView (created by View) in View in Unknown (created by Card) in RCTView (created by View) in View (created by Card) in Card (created by CardContainer) in CardContainer (created by CardStack) in RNSScreen in Unknown (created by InnerScreen) in Suspender (created by Freeze) in Suspense (created by Freeze) in Freeze (created by DelayedFreeze) in DelayedFreeze (created by InnerScreen) in InnerScreen (created by Screen) in Screen (created by MaybeScreen) in MaybeScreen (created by CardStack) in RNSScreenContainer (created by ScreenContainer) in ScreenContainer (created by MaybeScreenContainer) in MaybeScreenContainer (created by CardStack) in RCTView (created by View) in View (created by Background) in Background (created by CardStack) in CardStack (created by HeaderShownContext) in RCTView (created by View) in View (created by SafeAreaInsetsContext) in SafeAreaProviderCompat (created by StackView) in RNGestureHandlerRootView (created by GestureHandlerRootView) in GestureHandlerRootView (created by StackView) in StackView (created by StackNavigator) in PreventRemoveProvider (created by NavigationContent) in NavigationContent in Unknown (created by StackNavigator) in StackNavigator (created by CampaignResultGroup) in CampaignResultGroup (created by SceneView) in StaticContainer in EnsureSingleNavigator (created by SceneView) in SceneView (created by CardContainer) in RCTView (created by View) in View (created by CardContainer) in RCTView (created by View) in View (created by CardContainer) in RCTView (created by View) in View in CardSheet (created by Card) in RCTView (created by View) in View in Unknown (created by PanGestureHandler) in PanGestureHandler (created by PanGestureHandler) in PanGestureHandler (created by Card) in RCTView (created by View) in View in Unknown (created by Card) in RCTView (created by View) in View (created by Card) in Card (created by CardContainer) in CardContainer (created by CardStack) in RNSScreen in Unknown (created by InnerScreen) in Suspender (created by Freeze) in Suspense (created by Freeze) in Freeze (created by DelayedFreeze) in DelayedFreeze (created by InnerScreen) in InnerScreen (created by Screen) in Screen (created by MaybeScreen) in MaybeScreen (created by CardStack) in RNSScreenContainer (created by ScreenContainer) in ScreenContainer (created by MaybeScreenContainer) in MaybeScreenContainer (created by CardStack) in RCTView (created by View) in View (created by Background) in Background (created by CardStack) in CardStack (created by HeaderShownContext) in RCTView (created by View) in View (created by SafeAreaInsetsContext) in SafeAreaProviderCompat (created by StackView) in RNGestureHandlerRootView (created by GestureHandlerRootView) in GestureHandlerRootView (created by StackView) in StackView (created by StackNavigator) in PreventRemoveProvider (created by NavigationContent) in NavigationContent in Unknown (created by StackNavigator) in StackNavigator (created by AppRoutes) in AppRoutes (created by Routes) in EnsureSingleNavigator in BaseNavigationContainer in ThemeProvider in NavigationContainerInner (created by Routes) in Routes (created by RecruitRobinApp) in LoadingContextProvider (created by RecruitRobinApp) in ThemeProvider (created by RecruitRobinApp) in NotificationsContextProvider (created by RecruitRobinApp) in LocalizationContextProvider (created by RecruitRobinApp) in UserContextProvider (created by RecruitRobinApp) in RNCSafeAreaProvider (created by SafeAreaProvider) in SafeAreaProvider (created by RecruitRobinApp) in AuthContextProvider (created by RecruitRobinApp) in QueryClientProvider (created by RecruitRobinApp) in ErrorBoundary (created by RecruitRobinApp) in RecruitRobinApp (created by withDevTools(RecruitRobinApp)) in withDevTools(RecruitRobinApp) in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer in main(RootComponent), js engine: hermes

dai-shi commented 1 year ago

Also reported in https://github.com/dai-shi/react-tracked/issues/193

Can anyone help investigating it?

ftaibi commented 9 months ago

I had the same bug after updating to 0.73.4 I fixed it by installing the mentioned dependencies in the docs yarn add react-tracked react scheduler react-native

I realised i did not have scheduler installed

Brightbong92 commented 8 months ago

yarn add scheduer

i solved

fatwong commented 8 months ago

I believed the issue is caused by this: https://github.com/facebook/react-native/pull/37295, where react-native has upgraded their scheduler version to 0.24.0-canary-efb381bbf-20230505.

Which aims to use native scheduler if available. But I believed our package got some compatibility issue with this behaviour

Yet version 0.23.0 of scheduler is working well. So workaround from my side is to add codes below in my project's package.json like this:

"resolutions": {
    "scheduler": "^0.23.0",
},

@dai-shi I believed the issue occurs when https://github.com/facebook/react/pull/26554 is introduced to scheduler package, hope it can help you to dig deep. Thanks!

dai-shi commented 8 months ago

Yes, that helps!

https://github.com/facebook/react/pull/26554/files#diff-eb921830f4836b5599c46c6d747848478add9d3483644759d6c81b0ed6dbc453R107

causes the error. Thanks. I'll fix it.

dai-shi commented 8 months ago

Can anyone try #114?

https://ci.codesandbox.io/status/dai-shi/use-context-selector/pr/114 See "Local Install Instructions" ☝️

dai-shi commented 8 months ago

Published: https://www.npmjs.com/package/use-context-selector/v/1.4.2