Which package manager are you using? (Yarn is recommended)
npm
Summary
I had this hook on the root layout which is used to determine the first route of the app. (expo-router v1.7)
useLayoutEffect(() => {
const checkState = () => {
if (!navigationState?.key) {
// Temporary fix for router not being ready.
return;
}
if (!isLoggedIn) {
replace('(no-auth)/sign-in');
return;
}
if (locationGranted === undefined) {
replace('(no-auth)/sign-in/location');
return;
}
if (notificationGranted === 'undetermined') {
replace('(no-auth)/sign-in/notification');
return;
}
if (preferences.length === 0) {
replace('(no-auth)/sign-in/preferences');
return;
}
replace('(app)/(tabs)/dream');
};
checkState();
}, [
isLoggedIn,
locationGranted,
navigationState?.key,
notificationGranted,
preferences.length,
replace,
]);
then I upgraded to expo-router 2.0.2 and this doesn't work anymore because for some reason navigationState?.key keeps updating causing infinte render I tried updating the code to use rootNavigation.isReady() and the problem with that is that the app redirect after some seconds leaving me waiting in front of the no matched route screen. What should I do?
Which package manager are you using? (Yarn is recommended)
npm
Summary
I had this hook on the root layout which is used to determine the first route of the app. (expo-router v1.7)
then I upgraded to expo-router 2.0.2 and this doesn't work anymore because for some reason
navigationState?.key
keeps updating causing infinte render I tried updating the code to userootNavigation.isReady()
and the problem with that is that the app redirect after some seconds leaving me waiting in front of the no matched route screen. What should I do?Minimal reproducible example
Code provided above