[React.memo] Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`
See original GitHub issue "dependencies": {
"react": "^16.7.0-alpha1",
"react-dom": "^16.7.0-alpha1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.1"
},
How to reproduce:
- create-react-app try
- edit the App.js to the following:
import React, {memo} from "react";
import { BrowserRouter, Route } from "react-router-dom";
const Test = memo(() => <div>Quick Test</div>);
function App() {
return (
<BrowserRouter>
<Route path="*" component={Test} />
</BrowserRouter>
);
}
export default App;
-
yarn start, rendering works fine!
-
check the console:
index.js:1452 Warning: Failed prop type: Invalid prop
componentof typeobjectsupplied toRoute, expectedfunction. in Route (at App.js:10) in App (at src/index.js:7)
I fired this issue at https://github.com/mobxjs/mobx-react-lite/issues/12 as well.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:29 (4 by maintainers)
Top Results From Across the Web
Failed propType: Invalid prop `component` supplied to `Route ...
Warning : Invalid undefined `component` supplied to `Route`. The app is simple: import React from 'react'; import ReactDOM ...
Read more >Invalid prop `component` of type `object` supplied to `Route ...
[React.memo] Warning: Failed prop type: Invalid prop component of type object supplied to Route , expected function #6471.
Read more >React Top-Level API
React.memo only checks for prop changes. If your function component wrapped in React.memo has a useState , useReducer or useContext Hook in its ......
Read more >How To Customize React Components with Props
PropTypes are a simple type system to check that data matches the expected types during runtime. They serve as both documentation and an ......
Read more >Failed prop type: Material-UI: Either `children`, `image`, `src ...
[Solved]-Failed prop type: Material-UI: Either `children`, `image`, `src` or `component` prop must be specified in ForwardRef(CardMedia)-Reactjs.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Try using <Route render ={()=> < Test />} path=“path” /> rather than using the component prop.