purgeStoredState.js.flow 571 B

12345678910111213141516171819202122
  1. // @flow
  2. import type { PersistConfig } from './types'
  3. import { KEY_PREFIX } from './constants'
  4. export default function purgeStoredState(config: PersistConfig) {
  5. const storage = config.storage
  6. const storageKey = `${
  7. config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX
  8. }${config.key}`
  9. return storage.removeItem(storageKey, warnIfRemoveError)
  10. }
  11. function warnIfRemoveError(err) {
  12. if (err && process.env.NODE_ENV !== 'production') {
  13. console.error(
  14. 'redux-persist/purgeStoredState: Error purging data stored state',
  15. err
  16. )
  17. }
  18. }