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

Example starter boilerplate with server side rendering?

Open IzaGz opened this issue 7 years ago • 3 comments

Can anyone, please, provide some example implementation of using redux-logic and server side rendering (SSR) ?

IzaGz avatar May 30 '17 02:05 IzaGz

@IzaGz There's something in the making that I think will be really good, some assembly required. ;-)

  1. The react boilerplate project has an SSR PR built on version 3.4 that's close to production ready (not using redux-logic).

  2. 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.

gihrig avatar May 31 '17 05:05 gihrig

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

jeffbski avatar May 31 '17 13:05 jeffbski

Maybe someone is still in the midst of struggle:

fully working ssr solution https://github.com/yyynnn/redux-logic-ssr-boilerplate

yyynnn avatar Apr 19 '19 10:04 yyynnn