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';
26
26
const PERSISTENCE_KEY = ' NAVIGATION_STATE_V1' ;
27
27
28
28
export 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
30
30
const [initialState , setInitialState ] = React .useState ();
31
31
32
32
React .useEffect (() => {
33
33
const restoreState = async () => {
34
34
try {
35
35
const initialUrl = await Linking .getInitialURL ();
36
36
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
39
39
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 ;
41
43
42
44
if (state !== undefined ) {
43
45
setInitialState (state);
Original file line number Diff line number Diff line change @@ -26,18 +26,20 @@ import { NavigationContainer } from '@react-navigation/native';
26
26
const PERSISTENCE_KEY = ' NAVIGATION_STATE_V1' ;
27
27
28
28
export 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
30
30
const [initialState , setInitialState ] = React .useState ();
31
31
32
32
React .useEffect (() => {
33
33
const restoreState = async () => {
34
34
try {
35
35
const initialUrl = await Linking .getInitialURL ();
36
36
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
39
39
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 ;
41
43
42
44
if (state !== undefined ) {
43
45
setInitialState (state);
You can’t perform that action at this time.
0 commit comments