form2

1.1.5 • Public • Published

form2

React component to let you use form without use component state

NPM JavaScript Style Guide

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

/form2/

    Package Sidebar

    Install

    npm i form2

    Weekly Downloads

    11

    Version

    1.1.5

    License

    MIT

    Unpacked Size

    16.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • mhmdtshref