redux-universal icon indicating copy to clipboard operation
redux-universal copied to clipboard

Data fetching in onEnter

Open chentsulin opened this issue 9 years ago • 3 comments

As react-router's author say, onEnter should only use for redirect, see: https://github.com/rackt/react-router/issues/1389#issuecomment-146075183

Any ideas here?

chentsulin avatar Oct 07 '15 07:10 chentsulin

@chentsulin

If you don't mind waiting for your data to load before you transition, you can use onEnter to fetch data. But your page will feel sluggish because the router doesn't attempt to update state until all onEnter hooks are finished (so it knows if it needs to redirect or not).

They suggest it shouldn't be used, but in our case since we are using it for server side render, does it matter that the page feels sluggish? What do you think?

bshyong avatar Oct 11 '15 21:10 bshyong

Do they suggest any replacement for onEnter on pure client side? or there's other suggested approaches to handle async data loading (on the client) in the new router?

As to the server rendering, I'm 100% with you here.

coodoo avatar Oct 11 '15 23:10 coodoo

Any updates? I found this https://github.com/emmenko/redux-react-router-async-example Not sure if I like this solution

nodkrot avatar Apr 07 '16 14:04 nodkrot