Where should root component logic go in Expo Router apps? #140
Replies: 4 comments 2 replies
-
The question is also true for all kinds of providers like data store, themes, user state, etc. |
Beta Was this translation helpful? Give feedback.
-
Whichever |
Beta Was this translation helpful? Give feedback.
-
This may just be documentation lagging behind, but the referenced documentation for using the Splash Screen seems to be outdated. I would suggest using the sample expo app and take a look at the first _layout.tsx file: Here is the template I used:
This example will make initialization much clearer. |
Beta Was this translation helpful? Give feedback.
-
I am struggling with this in the context of HeadlessJS in Android. If I register a HeadlessJS task (through Background Fetch or through RNFirebase) in the outermost _layout.js file (outside the component itself just like we do it in App.js), it does not register the headlessJS task. I get "No task registered for key ReactNativeFirebaseMessagingHeadlessTask" in adb logs. Same for BackgroundFetch Headless task. So where do we put the HeadlessJS logic in Expo router (currently using V2) based apps ? I also tried using the HeadlessJS task in the index.js and that too does not work. I need HeadlessJS in my apps mainly to handle FCM notifications, but with the current gap in Expo Router, I am unable to use it. Is this a feature that needs enabling or a bug or am I just doing it wrong in Expo Router ? Note that I am using create-expo-app --template tabs project structure |
Beta Was this translation helpful? Give feedback.
-
Since
expo-router/entry
takes care of registering root component by using an internal<App />
component, where should initial app logic go now?Given the following app structure, for example, I want to load some custom fonts using
expo-font
. Usually that sort of stuff would be resolved inside of<App />
, but where should it go now? Is it root_layout
?Beta Was this translation helpful? Give feedback.
All reactions