-
Notifications
You must be signed in to change notification settings - Fork 348
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
[Bug]: loadingStatus state for react-google-charts is set as loading permanantly #710
Comments
@akshit-dev101 in our case it happened because we use Google Maps as well. When charts are loaded and then a user goes to GoogleMap screen, the problem you mentioned appears. It happens because google map react library deletes In the same time in the charts library, it is expected that if there is a script on the page, there should be |
@davoam any luck with the solution? |
We just work around the problem. This is code inside our component which shows charts. It removes script from the dom and forces the library to load chart again useLayoutEffect(() => {
if (!window.google) {
const script = document.querySelector('script[src="https://www.gstatic.com/charts/loader.js"]');
const scriptLoaded = script?.getAttribute('data-loaded');
if (script && scriptLoaded) {
script.remove();
}
}
}, []); I think you need to investigate your case. Probably, there is another reason. You can begin with checking value |
Currently, I have window.google as shown below, I tried using the code you provide, didn't work, but if I hard refresh the whole page the chart is visible @davoam, also I have the window.object , its not deleted as you said in the first comment.
|
Sorry, I have no ideas what else may cause the problem. Most likely, in your case, there is another reason. Try setting breakpoints in devtools inside the library code and check what happens. |
I had this same problem with my charts. After 1 week of tests, console.log for everything, etc I think I isolated the problem:
So I had to add a condition to only render the Chart if the data I'm going to send is a non-empty array or, at least, an empty array. I was setting a 'const [chartData, setChartData] = useState([]);' to store the data I was sending to the chart, and the console.log was printing 'undefined' at some of the renders. Hope this help someone avoid being very frustrated/angry/depressed because something that should work fine is not working. NOTE: just in case, I'm using React 17 |
Would you like to work on a fix?
Current and expected behavior
This is the state of the component even after all the rendering is done, it stays in loading, I tried the same code on code sandbox it worked fine.
Reproduction
Want able to reproduce this issue outside my project environment
react-google-charts version
v4.0.1
Possible solution
No response
The text was updated successfully, but these errors were encountered: