How it works...
In step 3, we set the initial height of the content. If the expanded property was set to true, then we should show the content. By setting the height value to null, the layout system will calculate the height based on the content; otherwise, we need to set the value to 0, which will hide the content when the component is collapsed.
In step 4, we defined all the JSX for the Panel component. There are a few concepts in this step worth covering. First, the children property is passed in from the props object, which will contain any elements defined between <Panel> and </Panel> when this component is used in the App class. This is very helpful because, by using this property, we are allowing this component to receive any other ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access