一个基于字段的表单库,适用于 React 和 React Native
Fielder
A field-first form library for React and React Native.
Fielder is a form library for React and React Native that has been built from the ground up with a field-first approach to validation.
⚡️ Synchronous validation - no cascading renders
Validation events - validation can differ per event (change, blur, submit, etc.)
Hooks that work - hooks respond to validation changes
Evolving schemas - validation logic evolves with the UI
Add Fielder to your project.
npm i fielderUse fielder or fielder/preact.
// React
import { useForm, ... } from 'fielder';
// Preact
import { useForm, ... } from 'fielder/preact';Use the useForm hook to create a form.
const myForm = useForm();
return {children};Use the useField hook to create a field.
const [usernameProps, usernameMeta] = useField({
name: 'username',
initialValue: '',
validate: useCallback(({ value }) => {
if (!value) {
throw Error('Username is required!');
}
}, []),
});
return (
<>
{usernameMeta.error}
);Once you're all set up, be sure to check out the guides for a deeper dive!
For more info, tutorials and examples, visit the official docs site!
Also check out:
暂无开放 Issues,或尚未同步最近议题。