Comparing version 2.0.1 to 2.0.2
@@ -308,3 +308,3 @@ import react, { FC, PropsWithChildren, MutableRefObject } from 'react'; | ||
declare const hasRequestAnimationFrame: () => boolean; | ||
declare const createCacheHelper: <Data = any, T = State<Data, any>>(cache: Cache, key: Key) => readonly [() => T, (info: T) => void, (key: string, callback: (current: any, prev: any) => void) => () => void]; | ||
declare const createCacheHelper: <Data = any, T = State<Data, any>>(cache: Cache, key: string | undefined) => readonly [() => T, (info: T) => void, (key: string, callback: (current: any, prev: any) => void) => () => void]; | ||
@@ -311,0 +311,0 @@ declare const mergeConfigs: (a: Partial<FullConfiguration>, b?: Partial<FullConfiguration>) => Partial<FullConfiguration<any, any, BareFetcher<unknown>>>; |
@@ -32,4 +32,6 @@ import React, { useEffect, useLayoutEffect, createContext, useContext, useMemo, useState, createElement, useRef, useCallback } from 'react'; | ||
(info)=>{ | ||
const prev = cache.get(key); | ||
state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE); | ||
if (!isUndefined(key)) { | ||
const prev = cache.get(key); | ||
state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE); | ||
} | ||
}, | ||
@@ -36,0 +38,0 @@ // Subscriber |
@@ -38,4 +38,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
(info)=>{ | ||
const prev = cache.get(key); | ||
state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE); | ||
if (!isUndefined(key)) { | ||
const prev = cache.get(key); | ||
state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE); | ||
} | ||
}, | ||
@@ -42,0 +44,0 @@ // Subscriber |
@@ -93,2 +93,3 @@ import { useRef, useMemo, useCallback, useDebugValue } from 'react'; | ||
const isInitialMount = !initialMountedRef.current; | ||
const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0; | ||
const cachedData = cached.data; | ||
@@ -104,2 +105,4 @@ const data = isUndefined(cachedData) ? fallback : cachedData; | ||
const shouldDoInitialRevalidation = (()=>{ | ||
// if a key already has revalidators and also has error, we should not trigger revalidation | ||
if (hasRevalidator && !isUndefined(error)) return false; | ||
// If `revalidateOnMount` is set, we take the value directly. | ||
@@ -106,0 +109,0 @@ if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount; |
@@ -94,2 +94,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const isInitialMount = !initialMountedRef.current; | ||
const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0; | ||
const cachedData = cached.data; | ||
@@ -105,2 +106,4 @@ const data = _internal.isUndefined(cachedData) ? fallback : cachedData; | ||
const shouldDoInitialRevalidation = (()=>{ | ||
// if a key already has revalidators and also has error, we should not trigger revalidation | ||
if (hasRevalidator && !_internal.isUndefined(error)) return false; | ||
// If `revalidateOnMount` is set, we take the value directly. | ||
@@ -107,0 +110,0 @@ if (isInitialMount && !_internal.isUndefined(revalidateOnMount)) return revalidateOnMount; |
{ | ||
"name": "swr", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "React Hooks library for remote data fetching", | ||
@@ -65,2 +65,22 @@ "keywords": [ | ||
"license": "MIT", | ||
"scripts": { | ||
"prepare": "husky install", | ||
"csb:install": "pnpm install", | ||
"csb:build": "pnpm build", | ||
"clean": "pnpm -r run clean", | ||
"watch": "pnpm -r run watch", | ||
"build": "pnpm build-package _internal && pnpm build-package core && pnpm build-package infinite && pnpm build-package immutable && pnpm build-package mutation", | ||
"build-package": "bunchee index.ts --cwd", | ||
"types:check": "pnpm -r run types:check", | ||
"prepublishOnly": "pnpm clean && pnpm build", | ||
"publish-beta": "pnpm publish --tag beta", | ||
"format": "prettier --write ./**/*.{ts,tsx}", | ||
"lint": "eslint . --ext .ts,.tsx --cache", | ||
"lint:fix": "pnpm lint --fix", | ||
"coverage": "jest --coverage", | ||
"test-typing": "tsc --noEmit -p test/type/tsconfig.json && tsc --noEmit -p test/tsconfig.json", | ||
"test-packaging": "publint", | ||
"test": "jest", | ||
"run-all-checks": "pnpm types:check && pnpm lint && pnpm test && pnpm test-typing" | ||
}, | ||
"lint-staged": { | ||
@@ -101,3 +121,3 @@ "*.{ts,tsx}": [ | ||
"rimraf": "3.0.2", | ||
"swr": "2.0.1", | ||
"swr": "workspace:*", | ||
"tslib": "2.4.1", | ||
@@ -122,21 +142,3 @@ "typescript": "4.9.4" | ||
"use-sync-external-store": "^1.2.0" | ||
}, | ||
"scripts": { | ||
"csb:install": "pnpm install", | ||
"csb:build": "pnpm build", | ||
"clean": "pnpm -r run clean", | ||
"watch": "pnpm -r run watch", | ||
"build": "pnpm build-package _internal && pnpm build-package core && pnpm build-package infinite && pnpm build-package immutable && pnpm build-package mutation", | ||
"build-package": "bunchee index.ts --cwd", | ||
"types:check": "pnpm -r run types:check", | ||
"publish-beta": "pnpm publish --tag beta", | ||
"format": "prettier --write ./**/*.{ts,tsx}", | ||
"lint": "eslint . --ext .ts,.tsx --cache", | ||
"lint:fix": "pnpm lint --fix", | ||
"coverage": "jest --coverage", | ||
"test-typing": "tsc --noEmit -p test/type/tsconfig.json && tsc --noEmit -p test/tsconfig.json", | ||
"test-packaging": "publint", | ||
"test": "jest", | ||
"run-all-checks": "pnpm types:check && pnpm lint && pnpm test && pnpm test-typing" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
224834
5065
1