Compose Hydrate Reducers for Redux Wrapper
Automatically handles the HYDRATE
action executed by next-redux-wrapper.
Installation
The easiest way to install compose-hydrate-reducers
is with npm.
npm install compose-hydrate-reducers
Alternately, download the source.
git clone https://github.com/stegano/compose-hydrate-reducers.git
Implementation
- Overwrite the client side state to the state delivered from the server side When the page is first rendered.
Example
...
const reducers = combineReducers(
composeHydrateReducers({
yourReducer1,
yourReducer2
...
});
)
type RootState = ReturnType<typeof reducers>;
const makeStore = () => createStore(reducers);
export const wrapper = createWrapper<Store<RootState>>(makeStore, { debug: true });
...