Nimble Package Maestros

    compose-hydrate-reducers
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.4 • Public • Published

    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

    // store.ts
    ...
    const reducers = combineReducers(
      /**
       * Reducers with `HYDRATE` action handling added is returned. 
       * ✨ Now you don't have to handle the `HYDRATE' operation directly on each reducer.
       */
      composeHydrateReducers({
        yourReducer1,
        yourReducer2
        ...
      });
    )
    
    type RootState = ReturnType<typeof reducers>;
    
    // create a makeStore function
    const makeStore = () => createStore(reducers);
    
    // export an assembled wrapper
    export const wrapper = createWrapper<Store<RootState>>(makeStore, { debug: true });
    ...

    Install

    npm i compose-hydrate-reducers

    DownloadsWeekly Downloads

    34

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    10.4 kB

    Total Files

    15

    Last publish

    Collaborators

    • stegano