title: how to change the address bar url from inside a react js component
body: <p>I am using the react js router to navigate around. Now my question is how can I change the url in address bar from inside a component?</p>
  <p>Suppose I have url as follows: <code>https://websitename/loc/lib/12</code>, and I have a dropdown list with some numbers which when selected, it should change the url above, ie: the number after the /lib/<code>...</code>&lt;--.</p>
  <p>What is the best way to modify it? Do I have to change it by pushing the change up the component till it reaches the page where the react router is declared? Or should I change it direclty in the page by using window.location.href?</p>
  <p>Information:</p>
  <pre><code>React version: 17.0.1
  React-router-dom: 4.3.1
  Using React js classes (not react hooks).
  </code></pre>