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.

Thank you for this very handy project! I have just made a PR to add it to Recharts (http://recharts.org), but there is a minor thing that makes them sort of incompatible.

React-container-dimensions is always sending its initial state (width and height set to zero) to the children components on the first render, and therefore Recharts prints multiple warns saying that it can’t render the charts in these conditions.

Can we send others values, other than zeros, to the children? What about having a third parameter hasInitiated, or send null as first values?

Link to the PR: recharts/recharts#105

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
zvictorcommented, May 25, 2016

Sorry, I couldn’t understand what you mean by since this is doable in the callback. Could you clarify it?

I think it is wrong to send { width: 0, height: 0 } in the first render because it is just conceptually wrong since the container does not have these dimensions. My understanding is that we should not be sending wrong data just because we don’t have the actual data.

So, to be able to get the real data (the container size), we need to render something in first place. Rendering null and then executing ReactDOM.findDOMNode(this).parentNode would fail. But we can’t render the children because we don’t have the dimensions yet. It is a circular dependency!

Therefore, we have three options:

  1. Render a placeholder element, get the container size, and only then render the actual children.
  2. Use values other than zero to denote that the values have not being initiated yet. This way, children would be able to know that when { width: null, height: null } it should wait for the next render.
  3. As mentioned before, having an attribute hasInitiated that we pass to the children so it is then aware that we don’t have the actual dimensions yet and we give the children the responsibility of dealing with it.

I am sending now a PR for the approach 1.

0reactions
zvictorcommented, May 25, 2016

thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Initial value problem - Wikipedia
In multivariable calculus, an initial value problem (IVP) is an ordinary differential equation together with an initial condition which specifies the value ......
Read more >
Initial Value Problem - YouTube
This calculus video tutorial explains how to solve the initial value problem as it relates to separable differential equations.
Read more >
Setting initial values
Initial values are a way of speeding up the interview by displaying questions with a certain answer or set of answers preselected.
Read more >
Initial value - CSS: Cascading Style Sheets - MDN Web Docs
For inherited properties, the initial value is used on the root element only, as long as no specified value is supplied. · For...
Read more >
Initial Values - Micro Focus
Initial values are used to ensure that all the data items used within a fragment are in their correct initial state when fragment...
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