Reputation: 89
I'm creating a notification reminder application in react native, I tried opening a specific screen in the application when user taps on the notification, I'm using react-navigation and tried deep linking with the screen paths. so my problem is, the deep-linked screen is opening fine when the app is foreground already, but if I open the notification when the app is closed(even not in recent), it goes to the deep-linked screen and immediately going back to the previous screen.
I'm doing some async operations in the useEffect
. not sure if this is the issue, help can be greatly appreciated.
useEffect(() => {
const paramObject = navigation.getParam('someObject', {});
if (Object.keys(paramObject).length === 0) {
const resourceID = navigation.getParam('resource_id', '');
const target = navigation.getParam('target', '');
axios.get().then(() => {
// some state setting
}).catch(); #Some api call
}
}, []);
Note: Problem occurs when the deeplink page opens when the app is closed, I'm also getting some warnings with the problem like Can't Perform react state update on a unmounted component ...
Upvotes: 1
Views: 1373
Reputation: 391
I think your problem is the app navigate to initial route.
Forced the deep linking to wait 1000ms before doing anything, so that sure that the app finished loading properly before anything.
Another approach would be to modify your dynamic initialRoute in order to recognize that the app has been opened by deep linking and to not do anything in that scenario.
Upvotes: 1