Skip to content

docs: clarify useWatch exact prop default behavior#1206

Merged
bluebill1049 merged 1 commit intoreact-hook-form:masterfrom
dfedoryshchev:docs/usewatch-exact-clarify
Apr 25, 2026
Merged

docs: clarify useWatch exact prop default behavior#1206
bluebill1049 merged 1 commit intoreact-hook-form:masterfrom
dfedoryshchev:docs/usewatch-exact-clarify

Conversation

@dfedoryshchev
Copy link
Copy Markdown
Contributor

The exact prop row in the useWatch props table only describes what true does and leaves the default behavior undefined. The reporter in #1035 notes they repeatedly have to read source to figure out what partial matching actually matches.

Source of truth (src/logic/shouldSubscribeByName.ts:3-18):

(exact
  ? currentName === signalName
  : currentName.startsWith(signalName) || signalName.startsWith(currentName))

So when exact is false, the subscription fires whenever the subscribed name is a prefix of the changed field name or vice versa. The dedicated test at src/__tests__/logic/shouldSubscribeByName.test.ts:9-12 pins this behavior (including the raw-string-prefix edge case where shouldSubscribeByName('test1', 'test') is truthy). Call site at createFormControl.ts:1196 invokes the function directly with no path normalization in between, so the prefix semantics apply end-to-end.

Single-row content change in src/content/docs/usewatch.mdx: replace the current one-liner with a description that states the default behavior in terms of the actual prefix check, with one concrete example for the typical nested-path case. No prettier reflow (the existing compute row already defines the column width).

Closes #1035.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 24, 2026

@dfedoryshchev is attempting to deploy a commit to the BEEKAI OSS Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2026

Deploy Preview for sage-cassata-31d224 ready!

Name Link
🔨 Latest commit 9c7b234
🔍 Latest deploy log https://app.netlify.com/projects/sage-cassata-31d224/deploys/69ebcb6ef11dd90007309025
😎 Deploy Preview https://deploy-preview-1206--sage-cassata-31d224.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@bluebill1049 bluebill1049 merged commit b3ff88d into react-hook-form:master Apr 25, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve documentation for useWatch exact

2 participants