Skip to content

Commit

Permalink
try catch for writeStagedState serialize rt2zz#1315
Browse files Browse the repository at this point in the history
  • Loading branch information
Emad-salah committed Aug 9, 2021
1 parent 32731fb commit 43a7b20
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/createPersistoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,19 @@ export default function createPersistoid(config: PersistConfig): Persistoid {
}
})

let serializedState
try {
serializedState = serialize(stagedState)
} catch (err) {
console.error(
'redux-persist/createPersistoid: error serializing state',
err
)
onWriteFail(err);
}

writePromise = storage
.setItem(storageKey, serialize(stagedState))
.setItem(storageKey, serializedState)
.catch(onWriteFail)
}

Expand Down

0 comments on commit 43a7b20

Please sign in to comment.