title: extract value from url using react router
body: <p>I have a URL link and I want to extract the value from that URL I am using react-router to access the value and here is the link of URL &lt;test/?salesoff=S4&amp;salesdist=District%201&amp;custname=C2&amp;product=P2&amp;productgroup=PG-1&gt; so using that URL I want to access each value and pass to data in the form fields and I am passing in routes path but I don't get any value here is my code I am passing</p>
  <pre><code>function App() {
    return (
      &lt;React.Fragment&gt;
        &lt;Router&gt;
          &lt;div className=&quot;imageStyle&quot;&gt;
            &lt;Switch&gt;
              &lt;Route exact path=&quot;/salesoff/:id/salesdist/:id/custname/:id/product/:id/productgroup/:id&quot; component={Form} /&gt;
            &lt;/Switch&gt;
          &lt;/div&gt;
        &lt;/Router&gt;
      &lt;/React.Fragment&gt;
    );
  }
  
  </code></pre>
  <p>Here is Form component where I am passing each value in input text field</p>
  <pre><code>export default function FormDesign() {
    axios.get('/url', {
    })
    .then(function (response) {
      console.log(response);
    })
  const handleChange = (event) =&gt; {
      setCurrency(event.target.value);
    };
  
    const onSubmit = (data) =&gt; console.log(JSON.stringify(data));
    return (
      &lt;div&gt;
        &lt;Grid&gt;
          &lt;Grid item xs={12} lg={6}&gt;
            &lt;Card&gt;
            
              &lt;Container component=&quot;main&quot; fixed&gt;
                  &lt;form
                    className={classes.form}
                    noValidate
                    onSubmit={(e) =&gt; onSubmit(e)}
                  &gt;
                    &lt;Grid container spacing={4}&gt;
                      &lt;Grid item xs={12} sm={6}&gt;
                        &lt;TextField
                          autoComplete=&quot;fname&quot;
                          name=&quot;salesoffice&quot;
                          variant=&quot;outlined&quot;
                          fullWidth
                          id=&quot;salesofice&quot;
                          label=&quot;Sales office&quot;
                          
                        /&gt;
                      &lt;/Grid&gt;
                      &lt;Grid item xs={12} sm={6}&gt;
                        &lt;TextField
                          type=&quot;text&quot;
                          variant=&quot;outlined&quot;
                          fullWidth
                          id=&quot;lastName&quot;
                          label=&quot;Billing document&quot;
                          name=&quot;lastName&quot;
                          autoComplete=&quot;lname&quot;
                        /&gt;
                       
                    &lt;Button
                      type=&quot;submit&quot;
                      fullWidth
                      variant=&quot;contained&quot;
                      color=&quot;primary&quot;
                      className={classes.submit}
                    &gt;
                      Submit
                    &lt;/Button&gt;
                    &lt;Grid container justify=&quot;flex-end&quot;&gt;
                      &lt;Grid item&gt;&lt;/Grid&gt;
                    &lt;/Grid&gt;
                  &lt;/form&gt;
                &lt;/div&gt;
                
              &lt;/Container&gt;
            &lt;/Card&gt;
          &lt;/Grid&gt;
        &lt;/Grid&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>