Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix maximum call stack size exceeded error on Tab component when using as={Fragment} #1826

Merged
merged 2 commits into from Sep 6, 2022

Conversation

RobinMalfait
Copy link
Collaborator

@RobinMalfait RobinMalfait commented Sep 6, 2022

The forceRerender is necessary when the Tab is rendered but the Panel isn't rendered yet (or vice versa) so that we can apply the correct attributes to link them together (e.g.: aria-controls).

However, if you are using a render prop, the contents is technically a bit different and it seems like we are calling the forceRerender while React is already updating which means that it has to update again, and again, and again.

Scheduling the forceRerender for the next frame allows React to complete the update and then we can forceRerender outside of the already going on update.

The `forceRerender` is necessary when the `Tab` is rendered but the
`Panel` isn't rendered yet (or vice versa) so that we can apply the
correct attributes to link them together (e.g.: `aria-controls`).

However, if you are using a render prop, the contents is technically a
bit different and it seems like we are calling the `forceRerender` while
React is already updating which means that it has to update again, and
again, and again.

Scheduling the `forceRerender` for the next frame allows React to
complete the update and then we can `forceRerender` outside of the
already going on update.
@vercel
Copy link

vercel bot commented Sep 6, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
headlessui-react ✅ Ready (Inspect) Visit Preview Sep 6, 2022 at 10:30AM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview Sep 6, 2022 at 10:30AM (UTC)

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.

None yet

1 participant