1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00
Files
checktheroads-hyperglass/hyperglass/ui/hooks/use-directive.ts
2021-12-19 23:02:01 -07:00

19 lines
547 B
TypeScript

import { useMemo } from 'react';
import { useFormState } from './use-form-state';
import type { Directive } from '~/types';
export function useDirective(): Nullable<Directive> {
const { getDirective, form } = useFormState(({ getDirective, form }) => ({ getDirective, form }));
return useMemo<Nullable<Directive>>(() => {
if (form.queryType === '') {
return null;
}
const directive = getDirective();
return directive;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [form.queryType, getDirective]);
}