Skip to content

Instantly share code, notes, and snippets.

@carvalhochris
Created March 7, 2023 12:50
Show Gist options
  • Select an option

  • Save carvalhochris/36b07bbb6450fd872ff2179e0dd1efdb to your computer and use it in GitHub Desktop.

Select an option

Save carvalhochris/36b07bbb6450fd872ff2179e0dd1efdb to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import MyComponent from './MyComponent';
function MyButton() {
const [showComponent, setShowComponent] = useState(false);
const handleClick = () => {
setShowComponent(true);
};
return (
<div>
<button onClick={handleClick}>Show Component</button>
{showComponent && <MyComponent />}
</div>
);
}
export default MyButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment