decord/alpha/source/hooks/usePrevious.tsx
github-actions 6eea20b8e1 chore: update source for alpha 348.3
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5014.js (118.4 MB)
2026-09-24 10:59:02 +00:00

51 lines
1.3 KiB
TypeScript

// Module ID: 8622
// Function ID: 8623
// Name: usePrevious
// Dependencies: [19, 2]
// Exports: default, useCurrentWhen, usePreviousWhen
// Module 8622 (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;
};