Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Data fetching in onEnter #6

Open
chentsulin opened this issue Oct 7, 2015 · 3 comments
Open

Data fetching in onEnter #6

chentsulin opened this issue Oct 7, 2015 · 3 comments

Comments

@chentsulin
Copy link
Contributor

As react-router's author say, onEnter should only use for redirect, see: remix-run/react-router#1389 (comment)

Any ideas here?

@bshyong
Copy link

bshyong commented Oct 11, 2015

@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?

@coodoo
Copy link

coodoo commented Oct 11, 2015

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.

@nodkrot
Copy link

nodkrot commented Apr 7, 2016

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants