React Router v4 nested routes not work with webpack-dev-server

后端 未结 5 1259
感情败类
感情败类 2021-01-13 06:50

I try to setup nested routes for my react app like this

  • / -> Home Page
  • /about -> About Page
  • /protected
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-13 07:03

    basically wrap, your react app using instead of working fine without any webpack config modification, if you don't want to use HashRouter then you can free to use historyApiFallback: true in web pack dev server config on bottom of webpack.config file

    like so
     const config = {
    
    ........
        devServer: {
            compress: true,
            port: 3000,
            https: false,
            historyApiFallback:true
        }
    }
    

提交回复
热议问题