Skip to content

Commit

Permalink
fix(async storage): setState in set hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Akurganow committed Jun 15, 2020
1 parent be4a1ad commit e287091
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/create-async-persisted-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default function createAsyncPersistedState(
const setPersistedState = async (newState: React.SetStateAction<T>): Promise<void> => {
const newValue = getNewValue<T>(newState, state)

setState(newValue)

const persistedItem = await storage.get(safeStorageKey)
const newItem = getNewItem<T>(key, persistedItem[safeStorageKey], newValue)

Expand Down

0 comments on commit e287091

Please sign in to comment.