From 634d1464f43cd2960bd94b626d4030c92f2a53ec Mon Sep 17 00:00:00 2001 From: Fayelure <38708022+Benjythebee@users.noreply.github.com> Date: Fri, 4 Aug 2023 10:24:59 +1200 Subject: [PATCH] Fix zustand warning (#872) * Fix zustand warning * use useStoreWithEqualityFn * eslint --- packages/core/package.json | 2 +- packages/core/src/hooks.ts | 3 ++- packages/store/package.json | 2 +- packages/types/package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index f2334db..970d0b4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -25,7 +25,7 @@ "dependencies": { "@web3-react/store": "^8.2.0", "@web3-react/types": "^8.2.0", - "zustand": "^4.3.5" + "zustand": "4.4.0" }, "peerDependencies": { "react": ">=16.8" diff --git a/packages/core/src/hooks.ts b/packages/core/src/hooks.ts index 716c4cd..0c92074 100644 --- a/packages/core/src/hooks.ts +++ b/packages/core/src/hooks.ts @@ -4,6 +4,7 @@ import { createWeb3ReactStoreAndActions } from '@web3-react/store' import type { Actions, Connector, Web3ReactState, Web3ReactStore } from '@web3-react/types' import { useEffect, useMemo, useState } from 'react' import { useStore } from 'zustand' +import { useStoreWithEqualityFn } from 'zustand/traditional' let DynamicProvider: typeof Web3Provider | null | undefined async function importProvider(): Promise { @@ -260,7 +261,7 @@ function getStateHooks(store: Web3ReactStore) { } function useAccounts(): Web3ReactState['accounts'] { - return useStore(store, ACCOUNTS, ACCOUNTS_EQUALITY_CHECKER) + return useStoreWithEqualityFn(store, ACCOUNTS, ACCOUNTS_EQUALITY_CHECKER) } function useIsActivating(): Web3ReactState['activating'] { diff --git a/packages/store/package.json b/packages/store/package.json index f0d4a28..e1cf4c3 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -25,6 +25,6 @@ "dependencies": { "@ethersproject/address": "^5", "@web3-react/types": "^8.2.0", - "zustand": "^4.3.5" + "zustand": "4.4.0" } } diff --git a/packages/types/package.json b/packages/types/package.json index 3dca357..4719aad 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -23,6 +23,6 @@ "start": "tsc --watch" }, "dependencies": { - "zustand": "^4.3.5" + "zustand": "4.4.0" } } diff --git a/yarn.lock b/yarn.lock index 1207e37..413b1af 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10115,9 +10115,9 @@ yargs@^17.6.2: y18n "^5.0.5" yargs-parser "^21.1.1" -zustand@^4.3.5: - version "4.3.6" - resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.3.6.tgz#ce7804eb75361af0461a2d0536b65461ec5de86f" - integrity sha512-6J5zDxjxLE+yukC2XZWf/IyWVKnXT9b9HUv09VJ/bwGCpKNcaTqp7Ws28Xr8jnbvnZcdRaidztAPsXFBIqufiw== +zustand@4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.4.0.tgz#13b3e8ca959dd53d536034440aec382ff91b65c3" + integrity sha512-2dq6wq4dSxbiPTamGar0NlIG/av0wpyWZJGeQYtUOLegIUvhM2Bf86ekPlmgpUtS5uR7HyetSiktYrGsdsyZgQ== dependencies: use-sync-external-store "1.2.0"