Skip to content

docs: document exact ancestor-path matching since 7.81.0 - #1231

Merged
bluebill1049 merged 1 commit into
react-hook-form:masterfrom
22mb:docs/exact-ancestor-matching
Aug 29, 2026
Merged

docs: document exact ancestor-path matching since 7.81.0#1231
bluebill1049 merged 1 commit into
react-hook-form:masterfrom
22mb:docs/exact-ancestor-matching

Conversation

@22mb

@22mb 22mb commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Since v7.81.0, a subscription with exact: true also fires when an ancestor path of the subscribed name is updated. Before 7.81.0, exact: true only matched the identical name. The reverse direction is unchanged: with exact: true, a change to a nested child path still does not notify a subscriber of the parent name (see react-hook-form/react-hook-form#12867).

The behavior changed in react-hook-form/react-hook-form#13553 (fixes react-hook-form/react-hook-form#13550, first released in v7.81.0), but neither the release notes nor the CHANGELOG mention exact, and the docs still describe exact: true as "an exact match for input name subscriptions". I ran into this when upgrading.

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

 (exact
-  ? currentName === signalName
+  ? currentName === signalName || currentName.startsWith(signalName + '.')
   : currentName.startsWith(signalName) ||
     signalName.startsWith(currentName)),

For a subscription to "users.0.name":

Change to exact: false exact: true (< 7.81.0) exact: true (>= 7.81.0)
"users.0.name" fires fires fires
"users.0" / "users" (ancestor) fires does not fire fires

For a subscription to "users", a change to "users.0.name" (descendant) fires only with exact: false — unchanged.

Changes

Updated the exact row in every props table that has one, following the existing <Since version="..." /> convention (as in #1206, #1216, #1219):

  • useWatch (usewatch.mdx), useFormState (useformstate.mdx), subscribe (useform/subscribe.mdx): describe both false and true, including the 7.81.0 ancestor-path behavior and the asymmetry.
  • useController (usecontroller.mdx), Controller (usecontroller/controller.mdx): same, phrased for the controlled field (default exact: true), with a hint that exact: false also receives nested updates.
  • Watch (usewatch/watch.mdx), FormState (useformstate/formstate.mdx): short version linking to the hook docs.
  • subscribe's exact type now shows its default (boolean = false), consistent with the other tables (exact is passed through as-is, so it is falsy unless set).

The rest of the diff is prettier re-padding the tables; pnpm format passes.

Since react-hook-form 7.81.0 (react-hook-form/react-hook-form#13553),
subscriptions with `exact: true` also fire when an ancestor path of the
subscribed name is updated. Changes to nested child paths still do not
notify with `exact: true`. Update the `exact` row in the useWatch,
useFormState, useController, Controller, Watch, FormState and subscribe
props tables accordingly, and show subscribe's default (`boolean = false`).
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@netlify

netlify Bot commented Aug 29, 2026

Copy link
Copy Markdown

Deploy Preview for sage-cassata-31d224 ready!

Name Link
🔨 Latest commit d168c9f
🔍 Latest deploy log https://app.netlify.com/projects/sage-cassata-31d224/deploys/6a9264ebc39a8900089a87bb
😎 Deploy Preview https://deploy-preview-1231--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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bluebill1049
bluebill1049 merged commit af8c57c into react-hook-form:master Aug 29, 2026
4 of 5 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.

issue: Clearing a value that is an object does not remove the value from useController

2 participants