Skip to content

Commit

Permalink
fix(boilerplate): fix deep link not working with navigation persist
Browse files Browse the repository at this point in the history
  • Loading branch information
vanenshi committed May 5, 2024
1 parent 4795ee1 commit 5da9270
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions boilerplate/app/navigators/navigationUtilities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect, useRef } from "react"
import { BackHandler, Platform } from "react-native"
import { BackHandler, Linking, Platform } from "react-native"
import {
NavigationState,
PartialState,
Expand Down Expand Up @@ -147,8 +147,11 @@ export function useNavigationPersistence(storage: Storage, persistenceKey: strin

const restoreState = async () => {
try {
const initialUrl = await Linking.getInitialURL()
const state = (await storage.load(persistenceKey)) as NavigationProps["initialState"] | null
if (state) setInitialNavigationState(state)

// Only restore the state if app has not started from a deep link
if (state && !initialUrl) setInitialNavigationState(state)
} finally {
if (isMounted()) setIsRestored(true)
}
Expand Down

0 comments on commit 5da9270

Please sign in to comment.