Skip to content

Commit a724593

Browse files
authored
Use wallets instead of wallets.length as useZap dependency (#2088)
* Potential fix for stale useZap wallet dependency * Memoize context value for wallets
1 parent 52365c3 commit a724593

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

components/item-act.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export function useZap () {
327327
// but right now this toast is noisy for optimistic zaps
328328
console.error(error)
329329
}
330-
}, [act, toaster, strike, wallets.length])
330+
}, [act, toaster, strike, wallets])
331331
}
332332

333333
export class ActCanceledError extends Error {

wallets/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,16 @@ export function WalletsProvider ({ children }) {
196196

197197
// provides priority sorted wallets to children, a function to reload local wallets,
198198
// and a function to set priorities
199+
const value = useMemo(() => ({
200+
wallets,
201+
reloadLocalWallets,
202+
setPriorities,
203+
onVaultKeySet: syncLocalWallets,
204+
beforeDisconnectVault: unsyncLocalWallets,
205+
removeLocalWallets
206+
}), [wallets, reloadLocalWallets, setPriorities, syncLocalWallets, unsyncLocalWallets, removeLocalWallets])
199207
return (
200-
<WalletsContext.Provider
201-
value={{
202-
wallets,
203-
reloadLocalWallets,
204-
setPriorities,
205-
onVaultKeySet: syncLocalWallets,
206-
beforeDisconnectVault: unsyncLocalWallets,
207-
removeLocalWallets
208-
}}
209-
>
208+
<WalletsContext.Provider value={value}>
210209
<RetryHandler>
211210
{children}
212211
</RetryHandler>

0 commit comments

Comments
 (0)