1.0.3 • Published 3 years ago

react-input-all v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

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.

NPM JavaScript Style Guide

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

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago