-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component / Route based async Server-Side Rendering #93
Comments
+1. Thanks for open sourcing this work! 🙏. Adding to @Chris-mE, it would be nice to have a more fleshed out "real world" SSR example. Initially I thought Electrode Redux Router Engine would help bootstrap initial state based on current route. Does something like redux-taxi or redux-connect make sense? It would be nice if Electrode provided a module for this or indicated best practices. |
Hi, thanks for reporting this. At the moment initializing redux store according to route in the router engine is not well defined so it's up the to user on how to do that. |
I found myself checking the current path at render. Not sure if this is the best approach but my code looks something like this.
|
@LeeFrancis Yeah that's the general approach I believe, though something like redux-connect, redux-taxi, or react-jobs seems like the way to go in terms of declaring the data requirements at the Component level. I'm leaning towards react-jobs because the work @ctrlplusb is doing in react-universally is pretty rad and he's active in moving with best practices. @jchip Thanks for the note. Keeping an eye on how this progresses. IMO the boilerplate is incomplete if it doesn't close the loop on the full server-side data flow and offer at least a recommended approach to the problem. My initial read of the electrode site led me to believe there was a module for this. |
@sbuys Thanks for the recommendation for these packages. I really liked the way redux-taxi works. |
@Chris-mE and whoever else is looking for a way to deal with this, I came up with a way to have declarative route-based redux store initializers, that also support async actions (and pre-fetching) for SSR. |
You can specify an |
hey @jchip thanks for the link but I could not find any example how to use the route init. What's inside that kind of handler? |
Anyways since I could not find a working example I came up with this approach:
This will fetch data server side only for the current route |
@hugotox Check my story at https://medium.com/@thedartcode/electrode-io-adventures-part-1-route-based-store-initialization-348f9c640843 I explain there both the solution proposed by the Electrode team as well as my take on the subject. I did something "custom" like you, only instead of adding |
First, thanks for this project!
I'd like to make an async fetch of data for the redux store, but only for a specific route / component that gets rendered server side. From the docs of 'redux-router-engine' I got this working:
But with this the 'yourAction' gets dispatched for every route. Is there a way / best-practice to do this only for specific routes / components?
Tank you!
The text was updated successfully, but these errors were encountered: