Some time ago, I implemented a splash screen by adding it as the first page to load in App.jsx
:
<Stack.Screen
name="SplashScreen"
component={SplashScreen}
options={{
headerShown: false,
}}
/>
However, I’ve recently noticed some problems. I added a context to my application, which retrieves a value from local storage.
The issue is that the context is loading before the splash screen, causing errors because the storage has not been initialized yet.
The splash screen is supposed to handle the storage initialization, but since I introduced this context, it loads before the splash screen. Am I using the splash screen incorrectly? Do you have any advice on how to properly load the splash screen at the start of the app?
index.js
:
<ApolloProvider client={client}>
<SocketContextProvider>
<App />
</SocketContextProvider>
</ApolloProvider>
No, I can’t move the storage logic inside the context. I could, but I don’t want to because in the context, we connect the user to socket.io, and this shouldn’t happen if we’re offline or not logged in. Only the splash screen will determine that.