profile
viewpoint

Ask questionsFailed prop type: Invalid prop 'component' supplied to 'Route': the prop is not a valid React component

I have a reference to an object containing getComponent(...) method for obtaining a React component. I try to render this component inside a nested route like so:

const component = React.cloneElement(object.getComponent(...), {...});
<Route path={`home/${object.route}`} component={component}/>;

and I get the following error: Failed prop type: Invalid prop 'component' supplied to 'Route': the prop is not a valid React component. I've seen similar issues like 6741 where the issue is resolved by upgrading the library version to react-router-dom@5.0.0, but my dependencies are up-to date:

"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-router-dom": "^5.0.0"

Any ideas on how can I solve this problem ?

ReactTraining/react-router

Answer questions support[bot]

:wave: @Kashio, we use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. For usage questions, please use Stack Overflow or Reactiflux where there are a lot more people ready to help you out. Please feel free to clarify your issue if you think it was closed prematurely.

useful!

Related questions

Cannot read property &#39;location&#39; of undefined at useLocation hot 9
Route is not exported in react-router-dom hot 6
Error: Invariant failed: You should not use <Switch> outside a <Router> hot 3
Replace componentWillMount by UNSAFE_componentWillMount for v3 hot 3
Use new forwardRef API in withRouter HOC hot 2
useParams returns empty object when used outside of Route hot 2
useParams and other new hooks are not exported in react-router-dom & react-router hot 2
react-router-dom v5 does not work with electron in production hot 2
Prompt in React 16 "Warning: A history supports only one prompt at a time" hot 1
Fix <Route children> hot 1
Route is not exported in react-router-dom hot 1
bug: react router dom 4.3.1 pulling react-router 4.4.0 changes after latest publish hot 1
[React.memo] Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function` hot 1
Receiving ESM Error but not using ESM hot 1
useParams and other new hooks are not exported in react-router-dom & react-router hot 1
source:https://uonfu.com/
Github User Rank List