open-amdocs / webrix

Powerful building blocks for React-based web applications
https://webrix.amdocs.com
Apache License 2.0
431 stars 31 forks source link

Avoid rendering content when collapsed #28

Open ykadosh opened 3 years ago

ykadosh commented 3 years ago

Currently, the Collapsible component renders its content regardless of whether it's expanded or not. It does so in order to be able to calculate the height to which it needs to expand.

This can lead to performance issues when you have many Collapsible elements on the screen. And even for a single item, it's redundant to render what the user doesn't see.

The solution is to not render the content when expanded is false, but when it's changing to true, render it collapsed, capture the height, and then expand.