Skip to content

skmail/reactjs-form

Repository files navigation

ReactJS-Form


NPM Version NPM Downloads Build Status codecov.io

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

About

A higher order component decorator for forms using React Component state

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published