Unable To Pass Props To Component Through React-router
I am unable to pass props using react-router. My code till now: import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter, Route, Switch } from 'react-rou
Solution 1:
This is the same problem as in this question. The problem is specific to the setup. As shown in error message, bundle.js
is loaded from current path, /edit/bundle.js
, while it should be loaded from /bundle.js
.
Scripts should either have absolute paths:
<scripttype="text/javascript"src="/bundle.js"></script>
Or base URL should be specified:
<base href="/">
Solution 2:
It may be an issue with your local environment, I dont see anyproblem with your code. I tried out in https://codesandbox.io/s/ox773ywmn9 and there is no issue
Solution 3:
I can access the props in the child components using this:
this.props.match.params.id
Post a Comment for "Unable To Pass Props To Component Through React-router"