Skip to content

[v2] Perf: Use one atom subscription per Field - #2358

Open
scttcper wants to merge 1 commit into
TanStack:alphafrom
scttcper:scttcper/field-subscriptions
Open

[v2] Perf: Use one atom subscription per Field#2358
scttcper wants to merge 1 commit into
TanStack:alphafrom
scttcper:scttcper/field-subscriptions

Conversation

@scttcper

@scttcper scttcper commented Aug 24, 2026

Copy link
Copy Markdown

Each React Field subscribed to the same atom twice, once for value and once for meta. The field atom already preserves state identity when neither changes, so use one whole-state subscription instead.

This cuts active subscriptions from two to one per field with the same render behavior.

Summary by CodeRabbit

  • Bug Fixes

    • Improved form field subscription handling to ensure updates are tracked consistently.
    • Preserved existing field API behavior while reducing redundant subscriptions.
  • Tests

    • Updated subscription coverage to verify that each field uses a single active subscription.

Each React Field subscribed to the same atom once for value and again for meta. The field atom already preserves state identity when neither changes, so one whole-state subscription has the same render behavior.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a39663b-a480-4f99-8fc7-ee3214ee7cf4

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad5a7b and 45ed204.

📒 Files selected for processing (2)
  • packages/react-form/src/ReactForm/fieldSubscriptions.lib.ts
  • packages/react-form/tests/FormGroup.spec.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The field subscription now observes the complete field state through one subscription. The field-context test description and expected active subscription count reflect this change.

Changes

Field subscription update

Layer / File(s) Summary
Unify field state subscription
packages/react-form/src/ReactForm/fieldSubscriptions.lib.ts, packages/react-form/tests/FormGroup.spec.tsx
useValueFieldSubscription subscribes to full field state and tracks that state for memoization. The test expects one active AppForm field-provider subscription.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 45ed2

This localized performance change reduces each field's atom subscriptions from two to one while preserving the stated render behavior; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: lecarbonator

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and motivation but omits the required Changes, Checklist, and Release Impact sections. Add the required template sections, complete the checklist, and indicate whether a changeset is required.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main performance change: reducing Field atom subscriptions from two to one.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@scttcper
scttcper marked this pull request as ready for review August 24, 2026 17:35
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.

1 participant