securityos/hooks/useProcessesRef.tsx

15 lines
442 B
TypeScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
import { useProcesses } from "contexts/process";
import type { Processes } from "contexts/process/types";
import { useEffect, useRef } from "react";
export const useProcessesRef = (): React.MutableRefObject<Processes> => {
const { processes } = useProcesses();
const processesRef = useRef<Processes>({} as Processes);
useEffect(() => {
processesRef.current = processes;
}, [processes]);
return processesRef;
};