1.0.3 • Published 3 years ago
react-input-all v1.0.3
react-input-all
React input is a lightweight, dependency free component for building forms in React without having to think about what happens under the hood. It uses one component and an array of objects that describe the inputs in the form.
Install
npm install --save react-input-all
Usage
import React, { useState } from "react";
import AllInput from 'react-input-all'
import 'react-input-all/dist/index.css'
const MyComponent = () => {
const [form, setForm] = useState([
{ name: 'name', value: '', placeholder: 'Write Your Name' },
{ name: 'email', value: '', placeholder: 'Write Your Email' },
{ name: 'phone', value: '', placeholder: 'Write Your Phone No.' }
])
const onBlurChange = (e, index) => {
let value = e.target.value
console.log('form data:>> ', form[index], 'event=>', e);
}
const handleChange = (e, index) => {
let value = e.target.value
console.log('form data:>> ', form[index], 'event=>', e);
}
return (
<AllInput
form_fields={form}
onBlurChange={onBlurChange}
handleChange={handleChange}
/>
)
}
export default MyComponent
License
MIT © harshilbunny