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 });
...

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    29
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    29
  • 1.0.3
    0
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i compose-hydrate-reducers

Weekly Downloads

29

Version

1.0.4

License

MIT

Unpacked Size

10.4 kB

Total Files

15

Last publish

Collaborators

  • stegano