-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Suspense showes warning when using ResponsiveContainer #2736
Comments
I fixed, you can't put height="50%" into ResponsiveContainer and width={"100%"}, the best way is put height={300}, width="100%" into ResponsiveContainer and the warning will disappear. |
i want both values to be percent, because it should match the parent size. it works perfect this way. but if i use the problem is, that it somehow gets a
After the Suspense is finished loading it will rerender again and looks normal. but the warning in the console is just annoying. |
What's your suggestion? |
Same problem here |
Ok, I believe I have figured out what is happening. When we use suspense, the "suspensed" content gets rendered in the DOM but with "display: none !important" by the react Suspense component. I strongly believe that is the reason for our warning. There's an issue on react github (here), its related to suspense do not be showing the children (removing the "display: none" style) after the promise / request get resolved. But what is important is this comment: here. Please, take a time to understand that solution, it is not complex. So we should render the chart only when suspense get false as value, I mean, when the promise / request get resolved. I really would love rechart team gave some attention to this, because those warnings are really annoying when you got a lot of responsive charts in the same screen, although honestly I can't figure out a really good solution.. Having a look at the ResponsiveContainer component here, maybe we could check if the div ".recharts-responsive-container" is visible someway of even its parent.. Ok, really don't know, but I hope to help other people by sharing that solution that verify if the suspense fallback Loader was unmounted. I'll let here my changes in the code:
Then, when inside the component which render the ResponsiveContainer I did:
That way my warning gone :) But please, give me a feedback, let me know your thoughts! Probably it could be improved someway. |
@williamisnotdefined is this still the method you are using? It's not working for me...specifically, in my debugging with some log statements, the |
We'll try to remove the log in 3.0. Or at least don't log it in production builds |
Same issue as #1686, but can't reopen it and it was closed without help.
Reproduction link
Steps to reproduce
Using a
ResponsiveContainer
inside aSuspense
and lazy load an element to triggerSuspense
.What is expected?
Warning should not be logged.
What is actually happening?
Suspense
will trigger following warning when theSuspense
is triggered by lazy loading an element inside of it:Code Example:
The text was updated successfully, but these errors were encountered: