Expand FragmentInstance reference docs#8309
Conversation
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
|
|
||
| Fragment `ref`s provide `focus`, `focusLast`, and `blur` methods that operate across all DOM nodes within the Fragment: | ||
|
|
||
| ```js {5-6} |
There was a problem hiding this comment.
Can we move this, and the other demos to Sandpacks?
|
|
||
| ```js | ||
| const observer = new IntersectionObserver(callback, options); | ||
| fragmentRef.current.observeUsing(observer); |
There was a problem hiding this comment.
Unrelated to this docs PR, but not sure where else to ask.
Is there a convenient way to get a list of refs from a fragment ref?
If not, this looks like something devs will find workarounds for 😄. cc @rickhanlonii might be worth reviewing this use case (and this whole post overall)
There was a problem hiding this comment.
Is there a convenient way to get a list of refs from a fragment ref?
The current design approach is to avoid coupling with specific children or parents. When the FragmentInstance handles coordination, things are more composable. You can refactor around Fragments without breaking dependent code.
Workarounds like this are possible but they put the responsibility on the user to handle edge cases. And we intentionally don't promote that pattern through a first-class API.
Preview