You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
571 B
23 lines
571 B
2 years ago
|
// @flow
|
||
|
|
||
|
import type { PersistConfig } from './types'
|
||
|
|
||
|
import { KEY_PREFIX } from './constants'
|
||
|
|
||
|
export default function purgeStoredState(config: PersistConfig) {
|
||
|
const storage = config.storage
|
||
|
const storageKey = `${
|
||
|
config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX
|
||
|
}${config.key}`
|
||
|
return storage.removeItem(storageKey, warnIfRemoveError)
|
||
|
}
|
||
|
|
||
|
function warnIfRemoveError(err) {
|
||
|
if (err && process.env.NODE_ENV !== 'production') {
|
||
|
console.error(
|
||
|
'redux-persist/purgeStoredState: Error purging data stored state',
|
||
|
err
|
||
|
)
|
||
|
}
|
||
|
}
|