title: How do I get url params with a question mark in react js?
body: <p>So I'm making a react app and I stumbled upon a problem that I couldn't figure out.
  I have a url <code>http://localhost/panel/?code=123456789</code>. How do I get <code>CODE</code>?</p>
  <p>I've tried this:</p>
  <pre class="lang-js prettyprint-override"><code>export default function App() {
      return (
        
        
        &lt;div className=&quot;App&quot;&gt;
          &lt;Router&gt;
  
          &lt;Switch&gt;
            &lt;Route exact path=&quot;/:code&quot; component={Panel}/&gt;
          &lt;/Switch&gt;
      &lt;/Router&gt;
          &lt;h1&gt;hi&lt;/h1&gt;
  
          &lt;/div&gt;
          
      
        );
  }
  
  function Panel(){
      const {code} = useParams();
          return (
          &lt;div&gt;
              &lt;h3&gt;ID: {code}&lt;/h3&gt;
          &lt;/div&gt;
      );
  }
  </code></pre>
  <p>but that gives me <code>ID: panel</code>. So I tried</p>
  <pre class="lang-js prettyprint-override"><code>          &lt;Route exact path=&quot;/panel/:code&quot; component={Panel}/&gt;
  </code></pre>
  <p>but then their is now no h3 or <code>ID:</code> on the page just the <code>&lt;h1&gt;hi&lt;/h1&gt;</code>.</p>
  <p>Does anybody know what I'm doing wrong? And how can I get <code>CODE</code>?</p>