stephane777
2/16/2020 - 5:14 PM

Update Webpack.config.js to make it work with webpack Dev serverf

OPEN Webpack.config.js

Without this the browser will say :"I don't have instruction on how to handle the url with the query string!"

The modification will be redirected to the index.html page and then React Router can handle the change and send the right Route.

  output :{
    publicPath: '/'
  }
  devServer :{
    historyApiFallback: true
  }

Extract of compile log when running npm start

  「wds」: Project is running at http://localhost:8080/
  「wds」: webpack output is served from /
  「wds」: Content not from webpack is served from /Users/steph08/Documents/Documents - Steph07's MacBook Pro/Tyler McGinnis/React/Hacker-News
  「wds」: 404s will fallback to /index.html
  「wdm」: wait until bundle finished: /
  「wdm」: Hash: 89d19e8bb9e62da2c26a
  
  
  
  
import { BrowserRouter as Router, Route } from "react-router-dom";

Passing props to a Route component

<Route path='/' render={(props)=> <Component {...props} propsTopass={propsTopass}>}> </Route