Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check PropTypes of React Router shows an error when I use lazy #6560

Closed
ae-lexs opened this issue Jan 26, 2019 · 1 comment
Closed

Check PropTypes of React Router shows an error when I use lazy #6560

ae-lexs opened this issue Jan 26, 2019 · 1 comment

Comments

@ae-lexs
Copy link

ae-lexs commented Jan 26, 2019

Check PropTypes of React Router shows an error when I use lazy

Hi, the console shows me an error when I use React.lazy.

Version

"react-router-dom": "4.3.1"

Test Case

https://codesandbox.io/embed/mjqr197v38

Steps to reproduce

import React, { lazy, Suspense } from "react";
import { render } from "react-dom";
import { BrowserRouter as Router, Route, Link } from "react-router-dom";

const About = lazy(() => import("./components/About"));
const Home = lazy(() => import("./components/Home"));
const Topics = lazy(() => import("./components/Topics"));

const BasicExample = () => (
  <Router>
    <Suspense fallback={<div>Loading...</div>}>
      <div>
        <ul>
          <li>
            <Link to="/">Home</Link>
          </li>
          <li>
            <Link to="/about">About</Link>
          </li>
          <li>
            <Link to="/topics">Topics</Link>
          </li>
        </ul>

        <hr />

        <Route exact path="/" component={Home} />
        <Route path="/about" component={About} />
        <Route path="/topics" component={Topics} />
      </div>
    </Suspense>
  </Router>
);

render(<BasicExample />, document.body);

Expected Behavior

It should not show me the error.

Actual Behavior


Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`.
    in Route (created by BasicExample)
    in BasicExample
@pshrmn
Copy link
Contributor

pshrmn commented Jan 26, 2019

Duplicate of #6420

@pshrmn pshrmn marked this as a duplicate of #6420 Jan 26, 2019
@pshrmn pshrmn closed this as completed Jan 26, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants