UNPKG

@modular-forms/react

Version:

The modular and type-safe form library for React

17 lines (16 loc) 555 B
import { useMemo } from 'react'; import { Form, Field, FieldArray } from '../components'; import { useFormStore } from './useFormStore'; export function useForm(options) { // Create form store const form = useFormStore(options); // Return form store and linked components return useMemo(() => [ form, { Form: (props) => Form({ ...props, of: form }), Field: (props) => Field({ ...props, of: form }), FieldArray: (props) => FieldArray({ ...props, of: form }), }, ], [form]); }