docs: clarify that useStore selector is required#2080
docs: clarify that useStore selector is required#2080dkpark10 wants to merge 1 commit intoTanStack:mainfrom
Conversation
|
📝 WalkthroughWalkthroughDocumentation clarification for the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/framework/react/guides/reactivity.md`:
- Line 27: The docs incorrectly state that the selector parameter is required;
update the text to say the selector is optional (signature uses selector?:) and
that it defaults to (state) => state, recommending its use for performance to
subscribe only to needed parts of form state; replace the sentence "The selector
parameter is required..." with wording that it is optional but recommended and
mention the default selector function and purpose (avoid unnecessary
re-renders).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cd1b8dbc-c120-45cf-ab39-25fe85740b72
📒 Files selected for processing (1)
docs/framework/react/guides/reactivity.md
| > Note, that `useStore` will cause a whole component re-render whenever the value subscribed to changes. | ||
|
|
||
| While it IS possible to omit the selector, resist the urge as omitting it would result in many unnecessary re-renders whenever any of the form state changes. | ||
| The selector parameter is required. It allows you to subscribe to only the specific part of the form state your component needs, helping avoid unnecessary re-renders when other parts of the state change. |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check the TypeScript signature of useStore to confirm if selector is required or optional
# Search for useStore function/hook definition
ast-grep --pattern $'export function useStore($$$) {
$$$
}'
# Also search for useStore type declarations
rg -nP --type=ts -C5 'function useStore|export.*useStore'
# Check for LocalSubscribe which wraps useStore
rg -nP --type=ts -C3 'function LocalSubscribe'Repository: TanStack/form
Length of output: 2673
🏁 Script executed:
# Check if `@tanstack/react-store` is in the packages directory
fd -t d "react-store" packages/
# If it's an external package, search for useStore definition in node_modules or find where it's defined
find packages -name "*react-store*" -o -name "*store*" | head -20
# Search for any TypeScript definition files mentioning useStore signature
rg -t ts "export.*function useStore|export.*useStore.*=" --max-count=10Repository: TanStack/form
Length of output: 98
🏁 Script executed:
# List all packages to find react-store
ls -la packages/ | grep -i store
# Search for type definitions of useStore
rg -t ts "selector\?" packages/ --max-count=20
# Look for .d.ts files that might have type signatures
fd -t f "\.d\.ts$" packages/ -x grep -l "useStore" {}
# Check package.json to understand the structure
find packages -name "package.json" -exec grep -l "react-store" {} \;Repository: TanStack/form
Length of output: 1108
🏁 Script executed:
# Read the documentation file to see line 27 and surrounding context
sed -n '20,35p' docs/framework/react/guides/reactivity.md
# Also check if there's a useStore definition in react-store package if it exists locally
find packages -name "react-store" -type dRepository: TanStack/form
Length of output: 773
The selector parameter is optional, not required.
The documentation claims the selector parameter is required, but the implementation across all form frameworks (React, Vue, Svelte, Solid, Angular) defines it as optional with selector?: and provides a default value (state) => state. Update the documentation to reflect that the selector parameter is optional but recommended for performance optimization.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/framework/react/guides/reactivity.md` at line 27, The docs incorrectly
state that the selector parameter is required; update the text to say the
selector is optional (signature uses selector?:) and that it defaults to (state)
=> state, recommending its use for performance to subscribe only to needed parts
of form state; replace the sentence "The selector parameter is required..." with
wording that it is optional but recommended and mention the default selector
function and purpose (avoid unnecessary re-renders).
🎯 Changes
#2035
Update the documentation to reflect that the
useStoreselector parameter is required.✅ Checklist
pnpm test:pr.🚀 Release Impact