diff --git a/package.json b/package.json index 33c28e7796..81ec0c9599 100644 --- a/package.json +++ b/package.json @@ -167,6 +167,7 @@ "trailingComma": "none" }, "dependencies": { + "dequal": "^2.0.3", "use-sync-external-store": "^1.2.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee979f3512..234663aad8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,13 +1,12 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: false - excludeLinksFromLockfile: false - importers: .: dependencies: + dequal: + specifier: ^2.0.3 + version: 2.0.3 use-sync-external-store: specifier: ^1.2.0 version: 1.2.0(react@18.2.0) @@ -2536,6 +2535,11 @@ packages: engines: {node: '>=0.4.0'} dev: true + /dequal@2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + dev: false + /detect-newline@3.1.0: resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} engines: {node: '>=8'} @@ -5648,3 +5652,7 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} dev: true + +settings: + autoInstallPeers: false + excludeLinksFromLockfile: false diff --git a/src/_internal/utils/config.ts b/src/_internal/utils/config.ts index a2eae1b3e4..ce05caea25 100644 --- a/src/_internal/utils/config.ts +++ b/src/_internal/utils/config.ts @@ -6,12 +6,14 @@ import type { ScopedMutator, Cache } from '../types' -import { stableHash } from './hash' + import { initCache } from './cache' import { preset } from './web-preset' import { slowConnection } from './env' import { isUndefined, noop, mergeObjects } from './shared' +import { dequal } from 'dequal/lite' + // error retry const onErrorRetry = ( _: unknown, @@ -37,8 +39,7 @@ const onErrorRetry = ( setTimeout(revalidate, timeout, opts) } -const compare = (currentData: any, newData: any) => - stableHash(currentData) == stableHash(newData) +const compare = dequal // Default cache provider const [cache, mutate] = initCache(new Map()) as [Cache, ScopedMutator]