import { useRef } from "react"; import { computed, IComputedValueOptions, IComputedValue } from "mobx"; export function useComputed(expr: () => T, options?: IComputedValueOptions): T { const ref = useRef>(); if (ref.current == null) { ref.current = computed(expr, options) } return ref.current.get(); }