Skip to content

Commit

Permalink
Merge pull request #1 from loveland/SethArchambault-serialize-trycatc…
Browse files Browse the repository at this point in the history
…h-patch-1

try catch for writeStagedState serialize
  • Loading branch information
SethArchambault authored Jun 17, 2021
2 parents d7efde9 + 76325cb commit 62b500c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/createPersistoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,17 @@ export default function createPersistoid(config: PersistConfig): Persistoid {
delete stagedState[key]
}
})

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

Expand Down

0 comments on commit 62b500c

Please sign in to comment.