score:1

Accepted answer

try using routes instead of switch.

  1. import routes
import { browserrouter , redirect, route , routes, switch } from 'react-router-dom';

  1. change the switch to *routes
        <routes>
          <route exact path="/" >
            <home />
          </route>
          <route path="/details" >
            <details />
          </route>
          <route path="*">
            <redirect to="/" />
          </route>
        </routes>

i hope this helps

score:1

upgrade to react-router-dom: version: 5.3.3 because version: 5.1 has bug.

1.uninstall whatever version you are having npm uninstall -s react-router-dom@5.1 npm uninstall -s react-router-dom

2.install react-router-dom: version: 5.3.3 npm install -s react-router-dom@5.3.3

or go to this post: click me to go to post


Related Query

More Query from same tag