Skip to content

Commit

Permalink
Remove timeout from setState
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbrasileiro committed Mar 25, 2022
1 parent d607a05 commit bb3cc65
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions packages/sdk/src/cart/Optimistic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export const OptimisticProvider = <T extends Item = Item>({

setIsValidating(false)
if (newCart != null) {
setTimeout(() => {
setCart(newCart)
}, 0)
setCart(newCart)
}
}

Expand Down
4 changes: 1 addition & 3 deletions packages/sdk/src/storage/useStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export const useStorage = <T>(key: string, initialValue: T | (() => T)) => {
const item = await getItem<T>(key)

if (!cancel && item !== null) {
setTimeout(() => {
setData(item)
}, 0)
setData(item)
}
}

Expand Down

0 comments on commit bb3cc65

Please sign in to comment.