New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-simple-hooks-forms

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-hooks-forms

Performatic forms for React/React Native using hooks api. Yes we're running out of names for React Forms with hooks.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
increased by155.56%
Maintainers
1
Weekly downloads
 
Created
Source

React Simple Hooks Forms

Performatic forms for React/React Native using hooks api. Yes we're running out of names for React Forms with hooks.

Installation

yarn add react-simple-hooks-forms

or

npm i react-simple-hooks-forms

Basic Usage

Build your inputs: (works with React and React Native)

import React from 'react'
import { useFormInput } from 'react-simple-hooks-forms'

export const TextFormField = (props) => {
    const { value, setValue } = useFormInput(props)
    const onChange = (e) => setValue(e.target.value)
    
    return <input
      name={props.name}
      value={value}
      onChange={onChange}
    />
}

Wrap your fields with the Form component:

import React from 'react'
import { useForm } from 'react-simple-hooks-forms'

const validator = (values) => {
  const errors = {}
  if (!values.name) {
    errors.name = 'Name is required'
  }
  return errors
}

const initialValues = { name: 'John' }

const App = () => {
  const { Form, submit } = useForm({ initialValues, validator })
  return <Form>
    <TextFormField name={'name'} />
    <TextFormField name={'email'} />
    <button onClick={submit}>
      Submit
     </button>
  </Form>
}

FAQs

Package last updated on 26 Jun 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc