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.lazy makes Route's proptypes fail

See original GitHub issue

Hello,

The newly introduced React.lazy for easy code-splitting is making the Route component proptypes to fail with the warning :

Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`.

Version

react-router-dom: 4.4.0-beta.4 react: 16.6.0

Test Case

I took the official example from here : https://reactjs.org/docs/code-splitting.html#route-based-code-splitting

https://codesandbox.io/s/xp2nwl2qxw

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:58
  • Comments:28 (7 by maintainers)

github_iconTop GitHub Comments

42reactions
tylerwraycommented, Oct 26, 2018

@rnnyrk I just did the following for now 🤷‍♂️

const Home = React.lazy(() => import('./Home')

<Route exact path="/" component={props => <Home {...props} />} />
22reactions
wulucxycommented, Dec 20, 2018

@pshrmn hey,when will you publish 4.4.0 version,this is a common problem。

Read more comments on GitHub >

github_iconTop Results From Across the Web

React.lazy makes Route's proptypes fail · Issue #6420 - GitHub
Hello, The newly introduced React.lazy for easy code-splitting is making the Route component proptypes to fail with the warning : Warning: ...
Read more >
React Router with React 16.6 Suspense "Invalid prop ...
The console warning is as follows: Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function ...
Read more >
Code-Splitting - React
React. lazy takes a function that must call a dynamic import() . This must return a Promise which resolves to a module with...
Read more >
Improve React Performance using Lazy Loading and Suspense
The Promise resolves if the module loads successfully and rejects if there was an error in loading the module, due to network failure,...
Read more >
How To Handle Async Data Loading, Lazy Loading, and Code ...
js Line 13:6: React Hook useEffect has a missing dependency: 'name'. Either include it or remove the dependency array react-hooks/exhaustive- ...
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