react-navigation / web

Tools for react-navigation on web browsers and servers
https://reactnavigation.org
MIT License
94 stars 28 forks source link

navigation.push is not a function #16

Open kasinskas opened 5 years ago

kasinskas commented 5 years ago

How can I navigate to the same route when passing different params? navigation.navigate doesn't re-render the page.

satya164 commented 5 years ago

Can you provide some code please?

kasinskas commented 5 years ago

Sure. I have such route:

const switchNavigator = createSwitchNavigator( { Details: { screen: DetailsScreen, path: 'details/:imdbId' }, ); const AppContainer = createBrowserApp(switchNavigator);

At the details screen user can click on some other recommended movie to see the details of it. So, for example, I need to go from /details/123 to /details/321.

navigation.navigate('Details', { title: movie.Title, imdbId: movie.imdbID, })

Since I'm building on mobile and web at the same time, I'm trying to reuse as much code as possible. That's why I tried to use navigation.push, but it doesn't exist.

navigation.navigate works in other cases, but here it doesn't re-render the page - imdbId in the url changes, but screen doesn't. I've also tried passing an unique key with no success. Dispatching a push action also doesn't work.

Should I just check if the url changed and rerender the page, or is there a better way?