Comparing version 5.0.0-rc.0 to 5.0.0-rc.1
@@ -17,5 +17,5 @@ import type { Draft } from 'immer'; | ||
} ? [] : T extends [unknown, unknown, ...infer A] ? A : T extends [unknown, unknown?, ...infer A] ? A : T extends [unknown?, unknown?, ...infer A] ? A : never; | ||
type SetStateType<T extends unknown[]> = Exclude<T[0], (...args: any[]) => any>; | ||
type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
type StoreImmer<S> = S extends { | ||
getState: () => infer T; | ||
setState: infer SetState; | ||
@@ -26,6 +26,6 @@ } ? SetState extends { | ||
} ? { | ||
setState(nextStateOrUpdater: T | Partial<T> | ((state: Draft<T>) => void), shouldReplace?: false, ...a: SkipTwo<A1>): Sr1; | ||
setState(nextStateOrUpdater: T | ((state: Draft<T>) => void), shouldReplace: true, ...a: SkipTwo<A2>): Sr2; | ||
setState(nextStateOrUpdater: SetStateType<A2> | Partial<SetStateType<A2>> | ((state: Draft<SetStateType<A2>>) => void), shouldReplace?: false, ...a: SkipTwo<A1>): Sr1; | ||
setState(nextStateOrUpdater: SetStateType<A2> | ((state: Draft<SetStateType<A2>>) => void), shouldReplace: true, ...a: SkipTwo<A2>): Sr2; | ||
} : never : never; | ||
export declare const immer: Immer; | ||
export {}; |
@@ -6,3 +6,3 @@ { | ||
"type": "commonjs", | ||
"version": "5.0.0-rc.0", | ||
"version": "5.0.0-rc.1", | ||
"publishConfig": { | ||
@@ -9,0 +9,0 @@ "tag": "next" |
@@ -7,11 +7,13 @@ 'use strict'; | ||
const { useRef } = ReactExports; | ||
const sliceCache = /* @__PURE__ */ new WeakMap(); | ||
function useShallow(selector) { | ||
const prev = useRef(); | ||
const key = useRef({}).current; | ||
return (state) => { | ||
const prev = sliceCache.get(key); | ||
const next = selector(state); | ||
return shallow.shallow(prev.current, next) ? prev.current : ( | ||
// It might not work with React Compiler | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
prev.current = next | ||
); | ||
if (shallow.shallow(prev, next)) { | ||
return prev; | ||
} | ||
sliceCache.set(key, next); | ||
return next; | ||
}; | ||
@@ -18,0 +20,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89035
1496