UNPKG

pocket-hook-form

Version:

pocket-store base hook form

13 lines (11 loc) 339 B
import {Store, useStore} from 'pocket-state'; import {FormState, FormStoreControl, FormValue} from '../models/type'; export function useFieldValue<T extends FormValue, K extends keyof T>( control: FormStoreControl<T>, name: K, ) { return useStore( (control as any)._store as Store<FormState<T>>, s => s.values[name], ); }