0.0.3 • Published 5 years ago

redux-state-cache v0.0.3

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

redux-state-cache

cache component state into redux store

Install

yarn add redux-state-cache

Usage

// createStore.js

import { cacheReducer } from 'redux-state-cache'

// ...
const reducerWithCache = cacheReducer(rootReducer)

const store = createStore(
  reducerWithCache
)
// ...


// componet.js
import { stateCache } from 'redux-state-cache'

@stateCache(
  'A_STATE_CACHE',
  (state, cache) => ({
    ...state,
    ...cache
  }),
  (state) => state
)
Class A extends React.Componet {
  state = {
    a: 1
  }
}