Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@kofile/react-form

Package Overview
Dependencies
Maintainers
38
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kofile/react-form

A form abstraction for react

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
38
Created
Source

react-form

Usage

import React from 'react'
import { Form } from '@kofile/react-form'

const config = {
  email: {
    validateOn: 'change',
    validateWith: v => v ? '' : 'error message'
  },
  password: {
    validateOn: 'blur',
    validateWith: v => v ? '' : 'fix your password!!!'
  }
}

class MyForm extends React.Component {
  handleSubmit = ({ formValues, isValid }) => {
    if (!isValid) {
      return
    }

    return handleSuccess(formValues)
  }

  render() {
    return (
      <div>
        <h2>My Awesome Form!</h2>
        <Form onSubmit={this.handleSubmit} config={config} render={(fields) => (
          <div>
            <label htmlFor={fields.email}>Email</label>
            <input {...fields.email.inputProps}/>
          </div>
          <div>
            <label htmlFor={fields.password}>Password</label>
            <input {...fields.password.inputProps}/>
          </div>
        )} />
      </div>
    )
  }
}

FAQs

Package last updated on 09 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts