File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,20 @@ import { NavigationContainer } from '@react-navigation/native';
2626const PERSISTENCE_KEY = ' NAVIGATION_STATE_V1' ;
2727
2828export default function App () {
29- const [isReady , setIsReady ] = React .useState (false );
29+ const [isReady , setIsReady ] = React .useState (Platform . OS === ' web ' ); // Don't persist state on web since it's based on URL
3030 const [initialState , setInitialState ] = React .useState ();
3131
3232 React .useEffect (() => {
3333 const restoreState = async () => {
3434 try {
3535 const initialUrl = await Linking .getInitialURL ();
3636
37- if (Platform . OS !== ' web ' && initialUrl == null ) {
38- // Only restore state if there's no deep link and we're not on web
37+ if (initialUrl == null ) {
38+ // Only restore state if there's no deep link
3939 const savedStateString = await AsyncStorage .getItem (PERSISTENCE_KEY );
40- const state = savedStateString ? JSON .parse (savedStateString) : undefined ;
40+ const state = savedStateString
41+ ? JSON .parse (savedStateString)
42+ : undefined ;
4143
4244 if (state !== undefined ) {
4345 setInitialState (state);
Original file line number Diff line number Diff line change @@ -26,18 +26,20 @@ import { NavigationContainer } from '@react-navigation/native';
2626const PERSISTENCE_KEY = ' NAVIGATION_STATE_V1' ;
2727
2828export default function App () {
29- const [isReady , setIsReady ] = React .useState (false );
29+ const [isReady , setIsReady ] = React .useState (Platform . OS === ' web ' ); // Don't persist state on web since it's based on URL
3030 const [initialState , setInitialState ] = React .useState ();
3131
3232 React .useEffect (() => {
3333 const restoreState = async () => {
3434 try {
3535 const initialUrl = await Linking .getInitialURL ();
3636
37- if (Platform . OS !== ' web ' && initialUrl == null ) {
38- // Only restore state if there's no deep link and we're not on web
37+ if (initialUrl == null ) {
38+ // Only restore state if there's no deep link
3939 const savedStateString = await AsyncStorage .getItem (PERSISTENCE_KEY );
40- const state = savedStateString ? JSON .parse (savedStateString) : undefined ;
40+ const state = savedStateString
41+ ? JSON .parse (savedStateString)
42+ : undefined ;
4143
4244 if (state !== undefined ) {
4345 setInitialState (state);
You can’t perform that action at this time.
0 commit comments