Replies: 1 comment
-
Thanks. Will be resolved in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Both Ark UI and Radix UI's "asChild" pattern suffer from a small performance issue compared to the polymorphic "as" prop. This is due to the usage of cloneElement, which causes this pattern to opt out of Reacts’s automatic re-render optimisation.
Here is the slot example:
https://github.com/chakra-ui/ark/assets/4128883/d7b33368-28de-4d57-973f-980a807cab53
The solution is to memoize the asChild component returned form the factory.

Link to Reproduction
https://codesandbox.io/p/sandbox/aschild-perf-issue-8hgfsm?file=%2Fsrc%2Fcomponents%2FExample.tsx%3A63%2C2
Steps to reproduce
Ark UI Version
0.15.0
Framework
Browser
Google Chrome Version 117.0.5938.149
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions