Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-automatic-form

airrobb20MIT1.0.2

Auto generate a form with any number of inputs

react-component, react

readme

React Automatic Form

React component that generates a form from an array of fields you'd like to include. Includes simple validation and callback to parent component passing back an object with the form data. Only supports input tags currently.

Usage

class Example extends React.Component {
  constructor(props) {
    super(props)
  }
  handleSubmit (formData){
    console.log(formData)
  }
  render() {
    const inputFields = [
      {
        name: 'name',
        type: 'text'
      },
      {
        name: 'email',
        type: 'email'
      },
      {
        name: 'color',
        type: 'text'
      }
    ]
    return (
      <AutomaticForm inputs={inputFields}
                     callBack={this.handleSubmit.bind(this)}
                     />
        )
  }
}

License

MIT