Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hookform/devtools

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hookform/devtools

React Hook Form dev tool to help debugging forms

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
288K
increased by3.67%
Maintainers
1
Weekly downloads
 
Created

What is @hookform/devtools?

@hookform/devtools is a development tool for React Hook Form, which provides a visual interface to debug and inspect forms created with React Hook Form. It helps developers to see the form state, errors, and other useful information in real-time.

What are @hookform/devtools's main functionalities?

Visual Form State Inspection

This feature allows developers to visually inspect the form state, including values, errors, and touched fields. The DevTool component is integrated into the form and provides a real-time view of the form's state.

import { DevTool } from '@hookform/devtools';
import { useForm } from 'react-hook-form';

function MyForm() {
  const { control, handleSubmit } = useForm();
  const onSubmit = data => console.log(data);

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstName" ref={control.register} />
      <input name="lastName" ref={control.register} />
      <button type="submit">Submit</button>
      <DevTool control={control} />
    </form>
  );
}

Error Debugging

This feature helps in debugging form errors by providing a visual representation of the errors in the form. The DevTool component shows the errors in real-time, making it easier to identify and fix issues.

import { DevTool } from '@hookform/devtools';
import { useForm } from 'react-hook-form';

function MyForm() {
  const { control, handleSubmit, errors } = useForm();
  const onSubmit = data => console.log(data);

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstName" ref={control.register({ required: true })} />
      {errors.firstName && <span>This field is required</span>}
      <input name="lastName" ref={control.register({ required: true })} />
      {errors.lastName && <span>This field is required</span>}
      <button type="submit">Submit</button>
      <DevTool control={control} />
    </form>
  );
}

Real-time Form Updates

This feature allows developers to see real-time updates of the form state as users interact with the form. The DevTool component provides a live view of the form's state, making it easier to track changes and debug issues.

import { DevTool } from '@hookform/devtools';
import { useForm } from 'react-hook-form';

function MyForm() {
  const { control, handleSubmit, watch } = useForm();
  const onSubmit = data => console.log(data);
  const firstName = watch('firstName');

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstName" ref={control.register} />
      <input name="lastName" ref={control.register} />
      <p>First Name: {firstName}</p>
      <button type="submit">Submit</button>
      <DevTool control={control} />
    </form>
  );
}

Other packages similar to @hookform/devtools

FAQs

Package last updated on 21 May 2020

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