0

I am switching over from react-native-router-flux to react-navigation v6.

I have my navigation wired up again for the most part, I am now struggling to navigate from app.js. I navigate from here only to handle notification navigation.

It seems like you can only access the navigation prop from screens that are stacks. I tried to add app.js to a stack but that did not work either...

I also tried the hook useNavigation() but I was not able to because app.js is a class component...

This was easy and out of the box with RNRF, is there something I am missing here with React Navigation v6?

hugger
  • 426
  • 4
  • 19
  • 1
    https://stackoverflow.com/q/49094140/13081108 You can check this – vatsal soni Feb 25 '23 at 04:25
  • @vatsalsoni hi, thanks for this. The deep linking looks promising but it is a whole new approach to what I have already implemented from RNRF. Do you know if it is possible without the need to deep link like this? If i could get access to the navigation prop here that would solve all my issues. – hugger Feb 25 '23 at 15:12
  • @vatsalsoni the more I look into deep linking, the more I see it is not for me. This is better for navigating from the browser if I were to implement this and I can see myself implementing this down the road. For my case, when a user presses a notification the notification passes a payload of data to my app.js and I need to pass that payload to the appropriate screen when navigating from app.js in the onNotificationReceived callback. I am unable to pass all these params with deep linking. – hugger Feb 25 '23 at 15:38
  • 1
    https://reactnavigation.org/docs/navigating-without-navigation-prop/ I was looking through the docs of navigation and found this maybe this can help – vatsal soni Feb 25 '23 at 16:31
  • 1
    @vatsalsoni you my friend are the best, this is exactly what I was looking for. Cheers! – hugger Feb 25 '23 at 17:47

1 Answers1

1

Navigating to screens with no access to navigation props using createNavigationContainerRef. More details (Added this to answer section from my comment)

vatsal soni
  • 359
  • 2
  • 9