Add a <RecoilRoot> wrapper for the whole app, before the NavigationStack
Run the app. Get this exception
iOS Bundling complete 1049ms
ERROR Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
4. You might be breaking the Rules of Hooks
5. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
RecoilRoot@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:135558:25
App
ExpoRoot@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:119162:22
RCTView
View
DevAppContainer@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:118879:36
RCTView
View
AppContainer@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:80503:36
main(RootComponent)@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:86878:28
ERROR Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
RecoilRoot@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:135558:25
App
ExpoRoot@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:119162:22
RCTView
View
DevAppContainer@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:118879:36
RCTView
View
AppContainer@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:80503:36
main(RootComponent)@http://192.168.1.10:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:86878:28
ERROR TypeError: null is not an object (evaluating 'dispatcher.useContext')
This error is located at:
in RecoilRoot (created by App)
in App (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in DevAppContainer (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in main(RootComponent)
ERROR TypeError: null is not an object (evaluating 'dispatcher.useContext')
This error is located at:
in RecoilRoot (created by App)
in App (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in DevAppContainer (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in main(RootComponent)
Works great until I add recoil as a dependency
Repro steps:
yarn add recoil
inside of /apps/xpo<RecoilRoot>
wrapper for the whole app, before the NavigationStack