redux-logic
redux-logic copied to clipboard
Example starter boilerplate with server side rendering?
Can anyone, please, provide some example implementation of using redux-logic and server side rendering (SSR) ?
@IzaGz There's something in the making that I think will be really good, some assembly required. ;-)
-
The react boilerplate project has an SSR PR built on version 3.4 that's close to production ready (not using redux-logic).
-
The react-bioilerplate-logic project is a fork of react-boilerplate 3.4 (no ssr) with redux-logic in place of redux-saga.
With a little study and file comparison it shouldn't be too hard to swap out the redux-saga in react-boilerplate SSR for redux-logic.
I need to create a few more examples and a recipe guide for situations like that. I can certainly help with the porting the SSR to react-boilerplate-logic.
In an nutshell the way I like to handle things for SSR is to use logic that listens for route change and fetches the data for that route. That allows things to work in either way, client fetched and server rendered. On the server , you basically dispatch the route change action and then call the logicMiddleware.whenComplete() to wait for all the fetching to finish before calling the render.
I start to describe this here but need to expand into a full example.
https://github.com/jeffbski/redux-logic/blob/master/docs/api.md#main-usage
Maybe someone is still in the midst of struggle:
fully working ssr solution https://github.com/yyynnn/redux-logic-ssr-boilerplate