Reputation: 71
On the first click of IconButton, the React component is shown and on the second click, I'd like to hide the component.
export default function EditorToolbar(props) {
const [open, setOpen] = React.useState(false);
const handleOpen = () => {
setOpen(true);
};
}
<IconButton size='small' onClick={handleOpen} >
Upvotes: 0
Views: 341
Reputation: 1548
export default function EditorToolbar(props) {
const [open, setOpen] = React.useState(false);
const handleOpen = () => {
setOpen(!open);
};
}
return(
<IconButton size='small' onClick={handleOpen} >
{open?show your react component here:null}
)
Upvotes: 2