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

后端 未结 2 1559
面向向阳花
面向向阳花 2020-12-15 16:50

This is the code of my webpack configuration:

const compiler = webpack({
  entry: [\'whatwg-fetch\', path.resolve(__dirname, \'js\', \'app.js\')], 
  module         


        
2条回答
  •  鱼传尺愫
    2020-12-15 17:18

    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.

    
    

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

    const About = () => (

    About

    );

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

提交回复
热议问题