Skip to content

react-hook-form/devtools-extension

Repository files navigation

Usage

  1. Install extension here
  2. Install devtools in your project
npm install @hookform/devtools -D
  1. Add <Devtool control={control}> in your code

    This won't show devtools component anymore! Just for extension detect your form.

  2. Enjoy!

Development

Install

Note use pnpm only

# extension
pnpm install
# example website
cd example
pnpm install

Start

  1. Start example website
cd example
pnpm run dev
  1. Start extension in development mode
pnpm run dev
  1. Open Chrome and navigate to chrome://extensions

  2. Enable Developer mode

  3. Click Load unpacked button and select /dist

Messaging Flow

sequenceDiagram
  participant Webpage
  participant Content Script
  participant Background
  participant Devtools
  participant Popup
  Background->>Background: Cleanup Cache
  Content Script->>Webpage: INIT
  Note left of Webpage: Browser has devtools extension
  Webpage->>Content Script: WELCOME
  Content Script->>Background: WELCOME
  Note right of Background: Webpage has rhf
  Background->>Background: Cache enabled tab
  par
    Popup->>Background: get-enable-status
    Background-->>Popup: Enable Status (Callback)
  and
    Devtools->>Background: get-enable-status
    Background-->>Devtools: Enable Status (Callback)
  end
  loop
    Webpage->>Content Script: UPDATE
    Content Script->>Background: UPDATE
    Note over Webpage,Background: Data
  end
  Background->>Background: Cache data
  loop Every 100ms
    Devtools->>Background: get-devtool-data
    Background-->>Devtools: Data (Callback)
  end
  Background->>Background: Cleanup Cache
Loading