Rikard
Product
One big issue with this is that this doesn't provide an accessible accordion. You also don't need to implement this in React since HTML provides the details and summary elements which give you native accordion functionality which is accessible as well, for free!
Nice! Just a quick reminder using native HTML elements is the easiest way to create an accessible accordion – no JS required!
<details> <summary>Section 1</summary> Hello this is my section. </details>Example of the above code (edit: Hashnode doesn't seem to use the same renderer for "preview" and after posting, so I had to take a screenshot of it)
See this for more details: css-tricks.com/quick-reminder-that-details-summar…