How to configure webpack dev server with react router dom v4? How to configure webpack dev server with react router dom v4? reactjs reactjs

How to configure webpack dev server with react router dom v4?


I do not think it has anything to do with webpack-config. Here is a basic github repository using react-router-4.0. I have created this example without any specific changes related to react-router-4.0 in webpack config.

Add 'devServer' in your webpack config if not already:

devServer: {    historyApiFallback: true,  }

Two small suggestions in your code, try using 'exact' with the path for 'about' i.e.

<Route exact path='/about' component={About}/>

and, add parenthesis for const about i.e.,

const About = () => (<div> <h1>About</h1> </div>);

Hope, this solves your query. Let me know if you require any other information on this.


In my case I had to remove proxy config, because the webpack server wanted a response from http://localhost:3001.

// proxy: {//   '/': 'http://localhost:3001',// },