Search code examples
reactjsstyled-components

Styled Components toggle display: none / block on another component


I'm trying to pass display: none / block with OnClick handler, to hide the component when clicking on the component I've been struggling for hours trying various options to no avail, is there any option to do so? Here is an example of the code on stackblitz to test https://stackblitz.com/edit/react-ru54gk?file=src/App.js


Solution

  • Why not using regular conditional rendering based on toggle?

    Something like this:

    {toggle && <ColorPicker />}

    https://stackblitz.com/edit/react-e4wnzk