import React, { useState } from 'react';
const Component = () => {
const [show, setShow] = useState(false);
return(
<>
<button onClick={() => setShow(prev => !prev)}>Click</button>
{show && <Box>This is your component</Box>}
</>
);
}
export default Component
{ this.state.showMyComponent ? <MyComponent /> : null }
{ this.state.showMyComponent && <MyComponent /> }