4

this is my first question on here, and maybe I am missing something simple but I cannot find my answer anywhere.

My project uses redux and has several "root" changes with both tabBasedApps and singleScreenApps. When using the drawer to deep link to a specific tab, if you are in the current tabBasedApp root, it will correctly go to the right tab with what I am using (below). But if you are in a different root of the application (tabs or single app) and have to change the root and then try to link to the correct tab - it doesn't work. It seems to skip over any navigator method and just print the console logs. So trying to get to "friends" from a different root just stops at "profile". I'm guessing it is a problem with the roots changing but I don't know.

Below is part of the event listener for the deep link. "appRoot" and "navigator" isn't "this.props..." because I am passing the nav event into a separate handler to reduce code duplication - it works with everything else I have tested, just not this (which I am assuming is not the handlers fault but I could be wrong).

I get a warning on iOS: Possible Unhandled Promise Rejection (id:0) Error: could not find UITabBarController Nothing on Android, it just doesn't work.

    if(event.type === 'DeepLink') {
        console.log('deeplink from nav');
        const parts = event.link.split('/');

        switch(parts[0]) {
            case 'profile':
                appRoot('profile');

                if(parts[1] === 'profile') {
                    navigator.toggleDrawer({
                        side: 'left',
                        animated: true,
                    });
                    navigator.switchToTab({
                        tabIndex: 0
                    });
                }

                if(parts[1] === 'friends'){
                    navigator.toggleDrawer({
                        side: 'left',
                        animated: true,
                    });
                    navigator.switchToTab({
                        tabIndex: 1,
                    });
                }
                break;

Steps to Reproduce: Build project using the redux example to be able to switch between roots. Have drawer with a button to go to a specific tab in one of the root tabBasedApps Handle the deep link from the drawer

Environment React Native Navigation version: ^1.1.352 React Native version: 0.51.0 Platform(s) (iOS, Android, or both?): both Device info (Simulator/Device? OS version? Debug/Release?): simulators on both. iphone 6 and Pixel 2

Thank you for any help!

Haugstack
  • 49
  • 4
  • did you ever find a solution for this? I am in the same boat as you. – mXX Jul 16 '19 at 07:35
  • Oof... I'm not sure. I really disliked the react nav system and my team actually moved to a PWA approach for dev testing. – Haugstack Jul 17 '19 at 12:50
  • 1
    But I think I passed in redux state with nav actions to the specific tab name I wanted and then checked that when the tab based component mounted to then force a tab change. Which obviously wasn't in the code above but in the action for whatever was making the nav redirect. I think I might have gone so far as to redux store the page the user was going to, and always check that when the tab based components loaded. – Haugstack Jul 17 '19 at 12:54
  • Cool! Thanks for getting back to me! – mXX Jul 18 '19 at 13:47

0 Answers0