title: Is it possible to write an if statement within the return of a functional component? ReactJS
body: <p>I want to toggle a few lines of code when a popup is open. I've setup the constant and button onClick, but I'm not sure if it's possible to write something like an if statement to do such a thing.</p>
  
  <p>I have tried to encapsulate the code in a single line if statement, but it clashes with the other inline code (the lastDroppedItem() section).</p>
  
  <p>Reason I want to toggle it is because the code below overlaps on the popup modal that's invoked within the code in Button.jsx that sits above it in the return statement.</p>
  
  <pre><code>const Frame = ({ accept, lastDroppedItem, onDrop }) =&gt;  {
    const [frame] = useState(pictureFrame);
    const [{ isOver, canDrop }, drop] = useDrop({
        accept,
        drop: onDrop,
        collect: (monitor) =&gt; ({
          isOver: monitor.isOver(),
          canDrop: monitor.canDrop(),
        })
    })
    const [popup, setPopup] = useState(false);
  
     const isActive = isOver &amp;&amp; canDrop
  
     return(
          &lt;div className="content"  ref={drop} &gt;
            {lastDroppedItem &amp;&amp; ( &lt;div className="animatedBox"&gt;&lt;Button onClick={ () =&gt; setPopup(true) } selectedIcon={lastDroppedItem.type}/&gt;&lt;/div&gt; )}
            &lt;img className="frame" alt="main frame" src={frame} /&gt;
  
             //starting here I want to toggle the below
            {lastDroppedItem &amp;&amp; (
              &lt;img className="selectedIcon content" alt={ lastDroppedItem.type + " icon"} src={setIcon(lastDroppedItem.type)} /&gt;
            )}
            &lt;div className="animatedBox"&gt;{isActive ? &lt;Pill text={"Drop icon into picture frame!"}/&gt;:
              &lt;Pill text={"Drag icons on the left into picture frame!"}/&gt; }&lt;/div&gt;
          &lt;/div&gt;
      );
  
  }
  
  export default Frame;
  </code></pre>
  
  <p>repo: <a href="https://github.com/WinsomeYuen/Artescence" rel="nofollow noreferrer">https://github.com/WinsomeYuen/Artescence</a></p>