Skip to content

Commit

Permalink
Persist documentation for Map & set improve getItem to include versio…
Browse files Browse the repository at this point in the history
…n only when present by way of spread operator on existingValue

--HG--
branch : discussion-2689-persist-doc-map-and-set-missing-version
  • Loading branch information
melutovich committed Aug 20, 2024
1 parent b0036b1 commit 0d6e3d2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/integrations/persisting-store-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,13 @@ interface BearState {
getItem: (name) => {
const str = localStorage.getItem(name);
if (!str) return null;
const { state, version } = JSON.parse(str);
const existingValue = JSON.parse(str);
return {
...existingValue,
state: {
...state,
transactions: new Map(state.transactions),
},
version
...existingValue.state,
transactions: new Map(existingValue.state.transactions),
}
}
},
setItem: (name, newValue: StorageValue<BearState>) => {
Expand Down

0 comments on commit 0d6e3d2

Please sign in to comment.