title: How to check for the route using react?
body: <p>i want to add spacing when the user is in page &quot;/items/:itemId&quot; using react.</p>
  <p>below is my snippet,</p>
  <pre><code>function child () {
      return (
          &lt;popupContext.Provider value={context}&gt;
              {children}
              {(condition1 || condition2) &amp;&amp; (
                  &lt;Popup onHide={on_hide} /&gt;
              )}
          &lt;/popupContext.Provider&gt;
      );
  };
  </code></pre>
  <p>So in the above snippet, if condition1 or condition2 is true and in any page it renders Popup component.</p>
  <p><strong>what i want to do?</strong></p>
  <p>now when user is in page &quot;/items/:itemId&quot; and condition1 or condition2 is true it should render Popup component along with  Spacing componet like below</p>
  <p>something like below</p>
  <pre><code>&lt;Route
      path=&quot;/items/:itemId&quot;
      render={routeProps =&gt; (
          &lt;Popup onHide={on_hide}/&gt;
          &lt;Spacing dir=&quot;x&quot; amount={16} /&gt;
      )}
  /&gt;
  </code></pre>
  <p>So basically when user is in path &quot;/items/:itemId&quot; and condition1 or condition2, i want to render popup and spacing components.</p>
  <p>when in page other than this and condition1 or condition2 i want to render only popup component.</p>
  <p>how do i rewrite above snippet such that when user is in any page other than &quot;/items/:itemId&quot; it should render only Popup component and when in page &quot;items/:itemId&quot; should render Popup with spacing component</p>
  <p>how can i fix this code. could someone help me with this. thanks.</p>