react-tiniest-form
Version:
the tiniest form
20 lines (19 loc) • 699 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useForm } from '../../hooks/Form/useForm';
import { createContext, useContext } from 'react';
const createFormContext = () => {
const FormContext = createContext(null);
const useFormContext = () => {
const method = useForm();
const context = useContext(FormContext);
if (!context)
return method;
return context;
};
const FormProvider = (props) => {
const { children, value } = props;
return _jsx(FormContext.Provider, { value: Object.assign({}, value), children: children });
};
return { FormProvider, useFormContext };
};
export default createFormContext;