I\'m trying new react-router 1.0.0 and I\'m getting strange warnings I can\'t explain:
Warning: Failed propType: Invalid prop `component` supplied to `Ro
This is definitely a syntax issue, when it happened to me I discovered I typed
module.export = Component;
instead of module.exports = Component;
There is an stable release on the react-router-dom
(v5) with the fix for this issue.
link to github issue
I solved this issue by doing this:
instead of
<Route path="/" component={HomePage} />
do this
<Route
path="/" component={props => <HomePage {...props} />} />
This question is a bit old, but for those still arriving here now and using react-router 4.3 it's a bug and got fixed in the beta version 4.4.0. Just upgrade your react-router to version +4.4.0. Be aware that it's a beta version at this moment.
yarn add react-router@next
or
npm install -s react-router@4.4.0-beta.8
In some cases, such as routing with a component that's wrapped with redux-form
, replacing the Route
component argument on this JSX element:
<Route path="speaker" component={Speaker}/>
With the Route
render argument like the following, will fix issue:
<Route path="speaker" render={props => <Speaker {...props} />} />