Files
discord-decomp/hooks/usePrevious.tsx
T
2026-11-01 12:12:55 +02:00

20 lines
469 B
TypeScript

// Metro module 8125 (f8126).
import { useEffect, useRef } from "react";
export default function usePrevious(a0) {
const current = a0;
const ref = useRef(null);
useEffect(() => {
ref.current = current;
}, [a0]);
return ref.current;
};
export function usePreviousWhen({ value, shouldUpdate }) {
const ref2 = useRef(null);
useEffect(() => {
if (shouldUpdate) {
ref2.current = value;
}
}, [value, shouldUpdate]);
return ref2.current;
}