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.

Warning appear during navigate process to component in <Route component={<Comp />} />?

See original GitHub issue

Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.

Description

Warning appears:

index.js:1 Warning: Cannot update a component from inside the function body of a different component.
    in Unknown (at loadable.tsx:27)
    in Suspense (at loadable.tsx:26)
    in Unknown (created by Context.Consumer)
    in Route (at App/index.tsx:96)
    in Switch (at App/index.tsx:95)
    in div (created by styled__MainWrapper)
    in styled__MainWrapper (at App/index.tsx:94)
    in div (created by styled__AppWrapper)
    in styled__AppWrapper (at App/index.tsx:86)
    in Unknown (at src/index.tsx:46)
    in HelmetProvider (at src/index.tsx:44)
    in Router (created by ConnectedRouter)
    in ConnectedRouter (created by Context.Consumer)
    in ConnectedRouterWithContext (created by ConnectFunction)
    in ConnectFunction (at src/index.tsx:43)
    in Provider (at src/index.tsx:42)
    in ConnectedApp (at src/index.tsx:53)

A clear and concise description of what the bug is. I think lazyLoad is problem Steps to reproduce the behavior:

(Add link to a demo on https://jsfiddle.net or similar if possible)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
receptiryakicommented, May 13, 2020

@cuongdevjs you need to use <Route render={routeProps => <Comp {...routeProps} />} /> instead of <Route component={<Comp />} />

https://reacttraining.com/react-router/web/api/Route/render-func

0reactions
Can-Sahincommented, May 15, 2020

well its really an ongoing discussion with no clear reasons. I dont see this error though. Probably related to your setup. If you can find out what the error is and where it originates from let us know with PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

how could I fix this mistake of routes in react - Stack Overflow
In react-router-dom version 6 the Route component API changed significantly, there are no longer component or render props.
Read more >
Create a ProtectedRoute for Logged In Users with Route ...
We'll combine a Route with a render prop and use a loggedIn prop to determine if the route ... const ProtectedRoute = ({...
Read more >
Route Component - Reach Router
Route Props - These props are passed to your component by Router when your component matches the URL: URL parameters and navigate are...
Read more >
A Complete Guide to Routing in React - Hygraph
In this guide, we will learn how to perform routing in React using React router, as well as the various aspects of routing...
Read more >
The Guide to Nested Routes with React Router - ui.dev
A solid understanding of how, when, and why to create nested routes is ... With Route out of the way, lets look at...
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