@contember/react-utils
Advanced tools
Comparing version 1.1.0 to 1.2.0-alpha.0
import { useMemo } from "react"; | ||
import { useConstantLengthInvariant } from "./useConstantLengthInvariant.js"; | ||
const useArrayMapMemo = (items, map) => { | ||
useConstantLengthInvariant(items); | ||
const mapped = useMemo(() => items.map(map), [map, ...items]); | ||
@@ -6,0 +4,0 @@ return useMemo(() => mapped, mapped); |
@@ -1,11 +0,2 @@ | ||
import { usePreviousValue } from "./usePreviousValue.js"; | ||
const useConstantLengthInvariant = (items, message) => { | ||
{ | ||
const previous = usePreviousValue(items); | ||
if (previous.length !== items.length) { | ||
throw new Error( | ||
`Invariant violation: ${message || "Changing the length of an array whose length must remain constant between renders."}` | ||
); | ||
} | ||
} | ||
}; | ||
@@ -12,0 +3,0 @@ export { |
@@ -1,11 +0,2 @@ | ||
import { usePreviousValue } from "./usePreviousValue.js"; | ||
const useConstantValueInvariant = (value, message) => { | ||
{ | ||
const previous = usePreviousValue(value); | ||
if (previous !== value) { | ||
throw new Error( | ||
`Invariant violation: ${message || "Changing a value which must remain constant between renders."}` | ||
); | ||
} | ||
} | ||
}; | ||
@@ -12,0 +3,0 @@ export { |
@@ -7,3 +7,3 @@ import { useRef, useEffect, useCallback } from "react"; | ||
useEffect(() => { | ||
return () => timerRef.current && clearTimeout(timerRef.current); | ||
return () => clearTimeout(timerRef.current); | ||
}, []); | ||
@@ -10,0 +10,0 @@ return useCallback(() => { |
@@ -18,2 +18,3 @@ import { useAbortController } from "./hooks/useAbortController.js"; | ||
import { returnTrue } from "./referentiallyStable/returnTrue.js"; | ||
import { useReferentiallyStableCallback } from "./referentiallyStable/useReferentiallyStableCallback.js"; | ||
export { | ||
@@ -36,4 +37,5 @@ emptyArray, | ||
usePreviousValue, | ||
useReferentiallyStableCallback, | ||
useSessionStorageState | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ import { useRef, useEffect, useCallback } from "react"; | ||
useEffect(() => { | ||
return () => timerRef.current && clearTimeout(timerRef.current); | ||
return () => clearTimeout(timerRef.current); | ||
}, []); | ||
@@ -10,0 +10,0 @@ return useCallback(() => { |
@@ -18,2 +18,3 @@ import { useAbortController } from "./hooks/useAbortController.js"; | ||
import { returnTrue } from "./referentiallyStable/returnTrue.js"; | ||
import { useReferentiallyStableCallback } from "./referentiallyStable/useReferentiallyStableCallback.js"; | ||
export { | ||
@@ -36,4 +37,5 @@ emptyArray, | ||
usePreviousValue, | ||
useReferentiallyStableCallback, | ||
useSessionStorageState | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,2 @@ | ||
/// <reference types="react" /> | ||
export declare const useForceRender: () => import("react").DispatchWithoutAction; | ||
//# sourceMappingURL=useForceRender.d.ts.map |
@@ -1,3 +0,2 @@ | ||
/// <reference types="react" /> | ||
export declare const useIsMounted: () => import("react").MutableRefObject<boolean>; | ||
//# sourceMappingURL=useIsMounted.d.ts.map |
@@ -7,2 +7,3 @@ export * from './emptyArray'; | ||
export * from './returnTrue'; | ||
export * from './useReferentiallyStableCallback'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@contember/react-utils", | ||
"license": "Apache-2.0", | ||
"version": "1.1.0", | ||
"version": "1.2.0-alpha.0", | ||
"type": "module", | ||
@@ -31,3 +31,4 @@ "sideEffects": false, | ||
"react": "^17 || ^18" | ||
} | ||
}, | ||
"stableVersion": "0.0.0" | ||
} |
@@ -9,3 +9,3 @@ import { useCallback, useEffect, useRef } from 'react' | ||
useEffect(() => { | ||
return () => timerRef.current && clearTimeout(timerRef.current) | ||
return () => clearTimeout(timerRef.current) | ||
}, []) | ||
@@ -12,0 +12,0 @@ |
@@ -7,1 +7,2 @@ export * from './emptyArray' | ||
export * from './returnTrue' | ||
export * from './useReferentiallyStableCallback' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
145
750
72832
2