Search code examples
reactjsreact-routerreact-router-redux

Resolve data before route change


I came from Angular 1 to be honest, I know a little bit angular 2, react. I know about this both architecture but I'm not confortable to produce fast app's like a guru.

I'm having a problem. In angular it is so easy, before the routes change, I can resolve or not my data to change the route including my controller/view.

How can I do this with reacting? So change the route as soon as my data is resolved. I do not find anything interesting out there.


Solution

  • If you are using react-router for navigation, then you can hook the onEnter and defer the call to callback until your data is resolved.

    https://github.com/ReactTraining/react-router/blob/v3/docs/API.md#onenternextstate-replace-callback