DEV Community

Discussion on: Creating an Accordion Component in React with Typescript and TailwindCSS

Collapse
 
brunowolf profile image
They Call Me Wolf

yeah! I used your article as a roadmap to implement an accordion on my React App menu! Thanks Julia!
A tiny suggestion (and as a thank you note)

setActive(active === false ? true : false)

to

setActive( !active )

Keep on coding in the free world!

Collapse
 
bionicjulia profile image
Bionic Julia

I'm so glad you found this useful. Ah, that's a great spot - thank you! :)

Collapse
 
bionicjulia profile image
Bionic Julia

Thinking about it more, perhaps this is even better to ensure it's fail-safe! :)

setActive((prevState) => !prevState)