form2
v1.1.5
Published
React component to let you use form without use component state
Downloads
5
Readme
form2
React component to let you use form without use component state
Install
npm install --save form2
Usage
import React, { Component } from 'react'
import Form from 'form2'
import './App.css'
export default class App extends Component {
render () {
return (
<div>
<Form fields={
[
{
type: 'text',
name: 'username',
placeholder: 'Type Username..',
id: 'username',
className: 'textField',
onChange: (event) => { console.log(`VALUE IS: ${event.target.value}`) }
},
{
type: 'text',
name: 'password',
placeholder: 'Type Password..',
id: 'password',
className: 'textField'
}]
} />
</div>
)
}
}
Field Types Supported
- Text field
Options
Options can be added on the fields options:
const myFields = [{ OPTIONS_HERE_AS_OBJECT_PROPERTIES }];
and you should send the myFields
array as a fields
props on the form2 component
<Form2 fields={myField} />
The fields options by type:
Text:
- type: required, should be => 'text'
- name: required, string
- Any input props (e.g: className, id, key, disabled ...)
License
MIT © mhmdtshref