1.0.8 • Published 5 years ago
react-form-in-second v1.0.8
React Form
Getting Started
Just add it and use
Installing
npm i --save react-form-in-second
or
yarn add react-form-in-second
Usage
import Form, { Input, Select, Custom, Checkbox } from 'react-form-in-second'
const Test = (props) => {
const { error, onChange, getFormData, value } = props
return <div>Hello from custom</div>
}
const App = () => {
const onSubmit = () => {
}
return (
<Form
title="Form Title"
className=""
onSubmit={onSubmit}>
<Input
label="User name:"
name="name"
validator={(value, formData) => {
console.log(value, formData)
return false
}}
errMsg="Error message for validation"
/>
<Checkbox
name="gender"
label="Male"
value={true}
validator={(value, formData) => {
console.log(value, formData)
}}
errMsg="Error message for validation"
/>
<Select
label="test"
name="fruit"
multiple
options={[
{value: 1, label: 'apple'},
{value: 2, label: 'banana'},
{value: 4, label: 'others', children: [
{value: 3, label: 'mango'},
]},
]}
validator={(value, formData) => {
console.log(value, formData)
}}
errMsg="Error message for validation"
/>
<Custom component={Test} />
<div>
<button type="submit" name="submit">Submit</button>
</div>
</Form>
)
}
for Development
- "npm i" or "yarn"
- npm run local
- open http://localhost:3000