decord/alpha/source/hooks/usePrevious.tsx
github-actions c6aa9eb120 chore: update source for alpha 349.3
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5030.js (118.4 MB)
2026-10-01 06:55:13 +00:00

51 lines
1.3 KiB
TypeScript

// Module ID: 7902
// Function ID: 7903
// Name: usePrevious
// Dependencies: [19, 2]
// Exports: default, useCurrentWhen, usePreviousWhen
// Module 7902 (usePrevious)
import noop from "module_19" /* 19 */;
import size from "module_2" /* 2 */;
({ useRef: closure_0, useEffect: closure_1 } = noop);
const result = size.fileFinishedImporting("hooks/usePrevious.tsx");
export default function usePrevious(current) {
const tmp = React(null);
closure_1 = tmp;
const items = [current];
framebus(() => {
closure_1.current = current;
}, items);
return tmp.current;
};
export const usePreviousWhen = function usePreviousWhen(value) {
value = value.value;
const shouldUpdate = value.shouldUpdate;
const tmp = React(null);
closure_2 = tmp;
const items = [value, shouldUpdate];
framebus(() => {
if (shouldUpdate) {
closure_2.current = value;
}
}, items);
return tmp.current;
};
export const useCurrentWhen = function useCurrentWhen(value) {
let current = value.value;
const shouldUpdate = value.shouldUpdate;
const tmp = React(null);
closure_2 = tmp;
const items = [current, shouldUpdate];
framebus(() => {
if (shouldUpdate) {
closure_2.current = current;
}
}, items);
if (!shouldUpdate) {
current = tmp.current;
}
return current;
};