question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:

  1. create-react-app try
  2. 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;
  1. yarn start, rendering works fine!

  2. check the console:

index.js:1452 Warning: Failed prop type: Invalid prop component of type object supplied to Route, expected function. 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:closed
  • Created 5 years ago
  • Reactions:12
  • Comments:29 (4 by maintainers)

github_iconTop GitHub Comments

26reactions
stack-wuhcommented, Mar 4, 2019

image i resolved it

23reactions
muralikrishnanacommented, Mar 2, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found