decord/stable/source/hooks/usePrevious.tsx
2026-10-06 22:12:49 +00:00

55 lines
1.3 KiB
TypeScript

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