How to fix Uncaught DOMException: Failed to execute 'pushState' on 'History'
You can use HashRouter or MemoryRouter instead BrowserRouter.
Just replace this line:
import { BrowserRouter, Route, Link, Switch } from 'react-router-dom';
with:
import { HashRouter, Route, Link, Switch } from 'react-router-dom';
or with:
import { MemoryRouter, Route, Link, Switch } from 'react-router-dom';
Then open your builded index.html file in the browser and everything should work like using localhost / dev server.
You should open your files via an Webserver. Because you cannot change location history on the file:// api.
I had this error (notwithstanding at my react app) because i provided instead of searchParams url, i put the whole url into the history.pushState http://localhost:9090/admin/model-type?PageNumber=2
but search query is expected ?PageNumber=2
history.pushState(
{[paramKey]: paramValue},
'page title',
url
)