-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add new "customKey" prop to ExpandableCard #2001
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this @kajalex.
Setting the key
prop doesn't seem to work for me here as I'm only getting the uuid. If I remove the uuid and test the key alone, then the id doesn't render. However, if I change the prop's name to something like customKey
then it works as expected. Do you know why this happens? I've had this issue previously with another component.
@anechol interesting! I was previously attempting with I've seen the pattern of passing a |
df9dc52
to
6d9f9b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, thanks a lot for this update, @kajalex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Description
Adds an optional "key" prop to the ExpandableCard react component.
When using ExpandableCard as a child component to a parent that's re-rendering on prop changes, the component appears to "flicker" due to re-rendering every time the
id
const changes. Internally, it's set to a newuuid()
on every render. We would like to provide an optional stable value via a prop so that we don't need to regenerate the id on every render.Screenshots
id
field utilized byButton
'saria-controls
and the child section(note: the framerate of the GIF recording doesn't catch the flickering super well, but it is visibly noticeable)
Testing in
sage-lib
Rails:
key
prop and verify that a key can be provided, which will set theid
of the button element. It should be a random uuid otherwise.React:
key
prop and verify that a key can be provided, which will set theid
of the button element. It should be a random uuid otherwise.Testing in
kajabi-products
key
prop for assigning IDs to child elements.Related
https://github.com/Kajabi/kajabi-products/pull/37105