lynx-form-x
Version:
LynxFormX is a lightweight and intuitive form library built for the Lynx framework for mobile development. It streamlines form management by automatically binding fields, handling validation, and providing easy-to-use hooks for custom field manipulation—a
13 lines (12 loc) • 437 B
JSX
import { useContext } from '@lynx-js/react';
import { formContext } from '../components/Form.jsx';
export const useField = (name) => {
const { values, errors, touched, setValue, setError } = useContext(formContext);
return {
value: values[name],
error: errors[name],
touched: touched[name],
setValue: (value) => setValue(name, value),
setError: (error) => setError(name, error),
};
};