[internal] Add JSDoc documentation for fastComponent and fastComponentRef#3781
[internal] Add JSDoc documentation for fastComponent and fastComponentRef#3781
Conversation
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: romgrk <1423607+romgrk@users.noreply.github.com>
Bundle size report
Check out the code infra dashboard for more information about this PR. |
|
@copilot Revert those changes and add documentation to |
Co-authored-by: romgrk <1423607+romgrk@users.noreply.github.com>
Done! Reverted the changes to |
| * - Clears the instance context after rendering | ||
| * | ||
| * **When to use:** | ||
| * - Use for components that make multiple `useStore` calls (React 19+) |
| * **Performance Optimization:** | ||
| * Components wrapped with `fastComponent` have access to a shared "instance" context that enables | ||
| * specialized hook implementations to batch operations and reduce overhead. The primary benefit is | ||
| * with `useStore` in React 19+, where multiple store subscriptions within the same component are | ||
| * batched into a single subscription, significantly reducing re-render overhead. | ||
| * | ||
| * **How it works:** | ||
| * - Creates a stable instance object that persists across renders | ||
| * - Sets the instance as the current context before rendering | ||
| * - Calls registered "before" hooks to prepare the instance | ||
| * - Renders the component function | ||
| * - Calls registered "after" hooks to finalize instance state | ||
| * - Clears the instance context after rendering |
There was a problem hiding this comment.
@copilot Make the How it works section much more compact and integrate it to the section before.
Co-authored-by: romgrk <1423607+romgrk@users.noreply.github.com>
Co-authored-by: romgrk <1423607+romgrk@users.noreply.github.com>
The
fastComponentandfastComponentRefwrapper functions lacked documentation explaining their performance optimization benefits, particularly the batched subscription optimization.Changes
fastComponentdocumentation:useStorecalls are batched into a single subscriptionfastComponentRefdocumentation:fastComponentwithReact.forwardReffastComponentfor performance detailsExample
The documentation is positioned at the wrapper functions where developers will encounter it when wrapping their components, making it more discoverable and contextually appropriate. The documentation is concise and focused on explaining what the functions do and their technical implementation.
Original prompt
useStore#3780💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.