site with details, additional info and examples -> https://topchagg.github.io/
npm install reactive-fast-formbash
npm install reactive-fast-form
`
Use the custom hook useCreateForm:
`javascript
const [form, setForm, trigger] = useCreateForm(['name']);
`
This hook takes the names of future fields as props.
Import the ReactiveForm element:
import { ReactiveForm } from "reactive-fast-form";
Use it! It takes an object and a function that returns useCreateForm, and it must have children.
Import the needed field (We’ll use InputField):
import InputField from "reactive-fast-form";
Use it with ReactiveForm like this:
`javascript
placeholder="Name"
validClass="valid default"
invalidClass="invalid default"
name="name"
isTrigger
/>
`
Every field requires the name prop.
name is a prop that specifies by what key you can get the value of this field from form.
isTrigger is a prop that must be present on one field of the entire form!
Create a submit button and use the setGlobalObject handler:
`javascript
`
This function takes a function returned from useCreateForm as a prop.
Use the custom hook useActionOnSubmit to handle the button click:
This function takes a callback function and trigger returned from useCreateForm as props.
Here’s the full code:
`javascript
import { useCreateForm, InputField, useActionOnSubmit, setGlobalObject, ReactiveForm } from "reactive-fast-form";
const DefaultInputFieldExample = () => {
const [form, setForm, trigger] = useCreateForm(["name"]);
useActionOnSubmit(() => {
alert(JSON.stringify(form["name"]));
}, trigger);
return (
<>
placeholder="Name"
validClass="valid default"
name="name"
isTrigger
/>
>
);
};
export default DefaultInputFieldExample;
``