Answer the question
In order to leave comments, you need to log in
Why does react router dom not find the page when refreshing the page?
What is the problem?
webpack.config
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.s[ac]ss$/i,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(jpe?g|png|gif|woff|woff2|eot|ttf|svg)(\?[a-z0-9=.]+)?$/,
loader: "url-loader?limit=100000",
},
],
},
};
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
<Router>
<>
<div className="site">
<div className="site-content">
<Header />
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/apps/" component={List} />
<Route exact path="/app/:slug" component={Detail} />
</Switch>
</div>
<Footer />
</div>
</>
</Router>
Answer the question
In order to leave comments, you need to log in
Add this set of options to your webpack.config.js
devServer: {
historyApiFallback: true,
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question