Closed molson504x closed 9 years ago
Can you verify that you are hitting the route handler method that creates the PreviewPage component after calling navigate? Navigate should just trigger a render() call on the component that has the RouteMixin applied to it.
Navigate doesn't do any magic, it's still up to the root component of your app (or Store if using a flux implementation) to make sure the current app state matches the current url.
I can confirm that both of those methods are getting hit... I think I see where I'm messing up. In my PreviewPage component, I'm doing my initial ajax call in my componentWillMount()
handler and never updating it in my componentWillUpdate()
.
Solution was to write a componentWillUpdate()
that makes the same ajax call as my componentWillMount()
and write a shouldComponentUpdate()
method to handle setting state on the callback from my ajax call. Without the shouldComponentUpdate()
you essentially DDoS yourself because it'll keep repeating the call.
Thanks for making a good component! I'm marking this as closed.
Great. Glad to hear you were able to solve your issue.
I've got a situation where I have to use navigate to the same route but with different parameters. My route is set up as:
I'm starting at the route
/preview/123456
and then using the navigate command to navigate to/preview/789012
:I'm able to see the URL change, however it seems like since I never changed the route and only changed the route parameters, the view never refreshes. I found a work-around where I update the state variable that holds the product information as part of the
changeProduct
function, but shouldn't Navigate() update the page regardless of the route changing or not?Thanks!