Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 827
João Silva Avatar asked Apr 16 '26 18:04

João Silva


1 Answers

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

like image 91
Ming Soon Avatar answered Apr 19 '26 07:04

Ming Soon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!