How to use redux-localstorage-simple - 10 common examples

To help you get started, we’ve selected a few redux-localstorage-simple examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github studiometa / react-next-starter / store / createStore.js View on Github external
export default (initialState = DEFAULT_STATE) => {
  // We do not want middlewares like redux-logger to get
  // fired on the server side

  if (isServer) {
    return createStore(reducers, initialState, applyMiddleware(thunk.withExtraArgument(socket)));
  } else {
    initialState = deepmerge(
      load({ states: localStorageStates, namespace: packageJson.name }),
      initialState,
    );
    return createStore(
      reducers,
      initialState,
      applyMiddleware(logger,
        save({ states: localStorageStates, namespace: packageJson.name }),
        thunk.withExtraArgument(socket)),
    );
  }

};
github joshwcomeau / tinkersynth / src / store / configure-store.prod.js View on Github external
export default function configureStore() {
  // In SSR, we can't access localStorage, so we need to build the store without
  // save/load support. I think this is fine though.
  let store;

  if (typeof window === 'undefined') {
    store = createStore(rootReducer);
  } else {
    store = createStore(
      rootReducer,
      load(reduxLocalStorageConfig),
      applyMiddleware(save(reduxLocalStorageConfig))
    );
  }

  return store;
}
github joshwcomeau / tinkersynth / src / store / configure-store.dev.js View on Github external
export default function configureStore() {
  const store = createStore(
    rootReducer,
    load(reduxLocalStorageConfig),
    compose(
      applyMiddleware(focusManagerMiddleware, save(reduxLocalStorageConfig)),
      DevTools.instrument()
    )
  );

  // Allow direct access to the store, for debugging/testing
  window.store = store;

  return store;
}
github joshwcomeau / tinkersynth / src / store / configure-store.prod.js View on Github external
export default function configureStore() {
  // In SSR, we can't access localStorage, so we need to build the store without
  // save/load support. I think this is fine though.
  let store;

  if (typeof window === 'undefined') {
    store = createStore(rootReducer);
  } else {
    store = createStore(
      rootReducer,
      load(reduxLocalStorageConfig),
      applyMiddleware(save(reduxLocalStorageConfig))
    );
  }

  return store;
}
github studiometa / react-next-starter / store / createStore.js View on Github external
export default (initialState = DEFAULT_STATE) => {
  // We do not want middlewares like redux-logger to get
  // fired on the server side

  if (isServer) {
    return createStore(reducers, initialState, applyMiddleware(thunk.withExtraArgument(socket)));
  } else {
    initialState = deepmerge(
      load({ states: localStorageStates, namespace: packageJson.name }),
      initialState,
    );
    return createStore(
      reducers,
      initialState,
      applyMiddleware(logger,
        save({ states: localStorageStates, namespace: packageJson.name }),
        thunk.withExtraArgument(socket)),
    );
  }

};
github danielrob / aperitif-editor / src / configureStore.js View on Github external
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
import { routerReducer, routerMiddleware } from 'react-router-redux'
import { save as makeSaver, load as makeLoader } from 'redux-localstorage-simple'

import { spyMiddleware } from 'middleware'
import appReducer from 'duck'

const save = makeSaver({ debounce: 1000 }) // middleware

// eslint-disable-next-line no-underscore-dangle
const composeEnhancers = (typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)
  // eslint-disable-next-line no-underscore-dangle
  ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ shouldHotReload: false })
  : compose

export default function configureStore(history) {
  const middleware = applyMiddleware(routerMiddleware(history), spyMiddleware, save)
  const enhancer = composeEnhancers(middleware)

  return createStore(
    combineReducers({
      app: appReducer,
      router: routerReducer,
    }),
github joshwcomeau / tinkersynth / src / store / configure-store.dev.js View on Github external
export default function configureStore() {
  const store = createStore(
    rootReducer,
    load(reduxLocalStorageConfig),
    compose(
      applyMiddleware(focusManagerMiddleware, save(reduxLocalStorageConfig)),
      DevTools.instrument()
    )
  );

  // Allow direct access to the store, for debugging/testing
  window.store = store;

  return store;
}
github Yoast / YoastSEO.js / examples / webpack / src / redux / utils / localstorage.js View on Github external
export function getStorageData( states = [], preloadedState = {} ) {
	return load( {
		states,
		namespace,
		preloadedState,
		disableWarnings: true,
	} );
}

redux-localstorage-simple

Save and load Redux state to and from LocalStorage.

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis