Trying to display components with react hooks

45 views Asked by At

I am trying to use React hooks to display a component when a button is pressed. I'm sure this is some simple syntax wrong here. Any guidance?

const [displayComponent, setDisplayComponent] = useState(null);

    function sendComponent() {
      setDisplayComponent(
      displayComponent = {<TheImportedComponentIWantToDisplay/>}
      )
    }

    return (

        <Button  onClick={sendComponent} >Push to render component</Button>

        {displayComponent}
)
0

There are 0 answers