decord/alpha/source/hooks/usePrevious.tsx

56 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-10-03 08:58:59 +00:00
// Module ID: 7946
// Function ID: 7947
2026-07-20 16:05:17 +00:00
// Name: usePrevious
2026-07-29 08:29:29 +00:00
// Dependencies: [19, 2]
2026-07-31 08:44:05 +00:00
// Exports: default, useCurrentWhen, usePreviousWhen
2026-07-20 16:05:17 +00:00
2026-10-03 08:58:59 +00:00
// Module 7946 (usePrevious)
import react from "react" /* 19 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let _window;
let map;
({ useRef: _window, useEffect: map } = react);
const result = size.fileFinishedImporting("hooks/usePrevious.tsx");
2026-07-20 16:05:17 +00:00
2026-10-03 08:58:59 +00:00
export default function usePrevious(arg0) {
const _window = arg0;
const tmp = React(null);
2026-10-03 08:58:59 +00:00
const items = [arg0];
tmp(() => {
closure_1.current = current;
2026-07-20 16:05:17 +00:00
}, items);
return tmp.current;
};
export const usePreviousWhen = function usePreviousWhen(value) {
value = value.value;
const shouldUpdate = value.shouldUpdate;
2026-10-03 08:58:59 +00:00
let tmp = React(null);
let closure_2 = tmp;
2026-07-20 16:05:17 +00:00
const items = [value, shouldUpdate];
2026-10-03 08:58:59 +00:00
map(() => {
const tmp = shouldUpdate;
if (tmp) {
closure_2.current = value;
2026-07-20 16:05:17 +00:00
}
}, items);
return tmp.current;
};
2026-07-31 08:44:05 +00:00
export const useCurrentWhen = function useCurrentWhen(value) {
let current = value.value;
const shouldUpdate = value.shouldUpdate;
2026-10-03 08:58:59 +00:00
let tmp = React(null);
let closure_2 = tmp;
2026-07-31 08:44:05 +00:00
const items = [current, shouldUpdate];
2026-10-03 08:58:59 +00:00
map(() => {
const tmp = shouldUpdate;
if (tmp) {
2026-08-24 06:08:38 +00:00
closure_2.current = current;
2026-07-31 08:44:05 +00:00
}
}, items);
if (!shouldUpdate) {
current = tmp.current;
}
return current;
};