Disabling a component within a component
Unanswered
Mandarin fish posted this in #help-forum
Mandarin fishOP
Does anyone know how to turn off or stop rendering a component when a button is pressed inside the component?
6 Replies
const [enabled, setEnabled] = useState(true)
...
return (
...
{enabled && <RenderMe />}
<button onClick={() => setEnabled(false)}>disable</button>
...
)return (
#Unknown Channel
<section></section>
</>
#Unknown Channel
<section></section>
</>
or
return opened ? <section /> : nullbtw, you shouldn't use onClick with a section tag
Mandarin fishOP
it's necessary, like when you click behind a block that will be inside this section to turn it off.