Files
outline/app/hooks/useComputed.ts
T
Tom MoorandGitHub 08a3b64295 chore: Exhaustive deps warning -> error (#13124)
* chore: Exhaustive deps turned to error

* Refactor useDragResize

* Refactor Lightbox to explicit state machine

* feedback

* ci
2026-07-25 10:43:49 -04:00

19 lines
614 B
TypeScript

import { computed } from "mobx";
import { type DependencyList, useMemo } from "react";
/**
* Hook around MobX computed function that runs computation whenever observable values change.
*
* @param callback Function which returns a memorized value.
* @param inputs Dependency list for useMemo.
*/
export function useComputed<T>(
callback: () => T,
inputs: DependencyList = []
): T {
// The dependency list is supplied by the caller so it cannot be verified here.
// eslint-disable-next-line react-hooks/exhaustive-deps
const value = useMemo(() => computed(callback), inputs);
return value.get();
}