title: React Router - What's the difference between Router and Switch?
body: <p>I'm trying to understand the difference between using Router and Switch in React Router.</p>
  <p>But I don't understand why using <strong>Switch</strong> in bellow example works:</p>
  <pre><code>import { BrowserRouter, Route, Switch } from 'react-router-dom';
  
  ReactDOM.render(
    &lt;React.StrictMode&gt;
       &lt;BrowserRouter&gt;
          &lt;Switch&gt;
              &lt;Route exact path=&quot;/&quot; component={App} /&gt;
              &lt;Route path=&quot;/item&quot; component={SocialMediaShare} /&gt;
          &lt;/Switch&gt;
      &lt;/BrowserRouter&gt;
    &lt;/React.StrictMode&gt;,
    document.getElementById('root')
  );
  </code></pre>
  <p>But using <strong>Router</strong> throws an error:</p>
  <pre><code>import { BrowserRouter, Route, Router } from 'react-router-dom';
  
  ReactDOM.render(
    &lt;React.StrictMode&gt;
       &lt;BrowserRouter&gt;
          &lt;Router&gt;
              &lt;Route exact path=&quot;/&quot; component={App} /&gt;
              &lt;Route path=&quot;/item&quot; component={SocialMediaShare} /&gt;
          &lt;/Router&gt;
      &lt;/BrowserRouter&gt;
    &lt;/React.StrictMode&gt;,
    document.getElementById('root')
  </code></pre>
  <p><a href="https://i.stack.imgur.com/VIEZ6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VIEZ6.png" alt="enter image description here" /></a></p>