Primitive for building forms in react.
I built formin to serve as a tiny (~1.5kb) alternative to other form solutions in react with these goals in mind
$ npm install formin
import { useFormin } from 'formin'
function Form() {
const { getInputProps, getFormProps } = useFormin({
onSubmit: ({ values }) => {
console.log(values)
},
})
return (
<form {...getFormProps()}>
<input {...getInputProps({ name: 'foo' })} />
<input {...getInputProps({ name: 'bar' })} />
<button>Submit</button>
</form>
)
}
import { Formin } from 'formin'
function MyForm() {
return (
<Formin
onSubmit={({ values }) => {
console.log(values)
}}
>
{({ getFormProps, getInputProps }) => (
<form {...getFormProps()}>
<input {...getInputProps({ name: 'foo' })} />
<input {...getInputProps({ name: 'bar' })} />
<button>Submit</button>
</form>
)}
</Formin>
)
}
Author: alexandernanberg
Demo: https://formin.netlify.com/
Official Website: https://github.com/alexandernanberg/formin
#reactjs #javascript