-
Notifications
You must be signed in to change notification settings - Fork 231
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
Error: react-d3-graph :: Graph :: you have not provided enough data for react-d3-graph to render something. You need to provide at least one node #347
Comments
Have you tried not rendering the component until the data is fetched? Ie have a "isLoading" (or something similar) state: if(!isLoading) -> render graph. |
@PraveenVutukuri please use the bug template when opening issues. Could you please add the version of Briefly looking into this, to avoid this kind of breaking behavior On the other hand, if you don't have data to render, then just don't mount the |
I think it should just draw an empty canvas if you provide a data object like following:
instead of throwing an error. |
Hi, |
Hey @gokul112 thanks for your interest. I think @LonelyPrincess might be looking into the same issue. Just to make sure we don't have two people working on this, I'll put this one on hold until we hear back from @LonelyPrincess. The solution we want to go with is to provide default data in case the client does not provide it. Just like pointed by @mailuesp above. |
Yeah, I agree in that it's best that we default the node list to an empty array and show a warning instead of throwing an error in these cases. It's true that the scenario in which someone uses the library to display an empty canvas is rare, but this is not really an error per se. A warning to tell the user that they forgot to pass down some data is enough to make them aware in case they didn't intend to leave that to happen. I'll upload a PR for this in a few minutes. 👍🏻 |
I am fetching the data from backend, it is throwing error
The text was updated successfully, but these errors were encountered: