import { useEffect, type DependencyList } from "react"; /** * `useEffect` for loading from the API and setting state from it (as Cross Events' lib/hooks.ts): * the React Compiler lint can't tell that apart from state derived from other state. */ export function useExternalEffect(run: () => void | (() => void) | Promise, deps: DependencyList) { useEffect(() => { const out = run(); return typeof out === "function" ? out : undefined; // The caller's deps, checked at the call site by exhaustive-deps (additionalHooks). // eslint-disable-next-line react-hooks/exhaustive-deps }, deps); }