reactjs-form
v0.1.18
Published
A higher order component decorator for forms using React Component state
Downloads
15
Maintainers
Readme
ReactJS-Form
reactjs-form
is a react library that allows html form validation within component state using minimal code and declarative way,
our validator uses skaterdav85/validatorjs package that inspired by Laravel PHP Validator
Example
import React, {Component} from 'react'
import Form from 'reactjs-form'
import TextInput from '../../components/text-input'
class SingleInput extends Component {
constructor(props) {
super(props)
this.onSubmit = this.onSubmit.bind(this)
}
render() {
const {
inputComponent:Input,
submitting
} = this.props
return (
<form onSubmit={this.onSubmit}>
<Input
name="email"
type="email"
label="Email Address"
component={TextInput}
/>
</form>
)
}
onSubmit(e) {
e.preventDefault()
this.props.validate().then(() => {
// continue
}).catch(() => {})
}
}
export default Form(SingleInput, {
rules: {
email: "required|email"
}
})
Installation
npm install --save reactjs-form
or yarn add reactjs-form
Docs
Check out the Documentation
Demo
npm run examples
or yarn examples