So I\'m trying to set up an Office-js excel add-in using react (using the yeoman office-js generator found here https://github.com/OfficeDev/generator-office) and am running int
I had the same issue, and the solution I used was essentially following @Ragavan Rajan's solution of using HashRouter
instead of BrowserRouter
.
import {
HashRouter as Router,
Switch,
Route
} from "react-router-dom";
...
render() {
return (
<Router>
<div>
<Switch>
<Route exact path="/main" component={Home} />
</Switch>
</div>
</Router>
);
}
This answer provides more insight. Ultimately, two functions which are used in maintaining a history of where you have navigated are set to null:
window.history.replaceState = null;
window.history.pushState = null;
and when you try to use the normal browser routing, an exception if thrown because these functions don't exist, which doesn't happen with Hash Routing.