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

form-hooks

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form-hooks - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

1

lib/index.js

@@ -126,2 +126,3 @@ "use strict";

handleSubmit: handleSubmit,
setErrors: setErrors,
isSubmitting: isSubmitting,

@@ -128,0 +129,0 @@ submitCount: submitCount

2

package.json
{
"name": "form-hooks",
"version": "0.1.0",
"version": "0.2.0",
"description": "Easy forms in React with hooks",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -60,2 +60,62 @@ # form-hooks

## Documentation
### `useForm` - `options`
The `useForm` hook takes some options (as an object) to initialize state
and manage form validation/submissions.
#### `initialValues`
An object with the forms initial values. These values should not be required.
#### `onSubmit(values)`
Called when a form is submitted with the values set. Only called if validation
passes.
#### `validate(values)`
Called when a form is submitted prior to the `onSubmit` call. Returns an object
of errors similar to `Formik`.
### `useForm` - returned
#### `errors`
An object that contains the form errors where the key is the field name
and the value is the error message.
#### `touched`
An object that contains which form fields have been touched. The key is
the field name, the value is a boolean of if the field has been touched.
#### `values`
An object that contains all of the values of the form. Initialized with the
`initialValues` originally passed in. Modified by the `handleChange` handler.
#### `handleBlur`
Marks a field as `touched` to show errors after all fields are touched.
#### `handleChange`
Changes the fields value in the `values` state.
#### `handleSubmit`
Handles calling validation prior to the `onSubmit` handler and setting the
`touched`, `errors` and `isSubmitting` state internally.
#### `isSubmitting`
Boolean value if the form is currently submitting.
#### `setErrors`
Function that allows for errors to be set outside of the `useForm`
internal handlers (good for handling request errors).
[Formik]: https://github.com/jaredpalmer/formik
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