Skip to content
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

TypeError: Cannot read properties of undefined (reading 'load') #237

Open
Arkk92 opened this issue Jul 7, 2023 · 4 comments
Open

TypeError: Cannot read properties of undefined (reading 'load') #237

Arkk92 opened this issue Jul 7, 2023 · 4 comments

Comments

@Arkk92
Copy link

Arkk92 commented Jul 7, 2023

Since looks like no one is updating the module I'm writing this issue to whom may be interested in solving the error in the title:

Screenshot from 2023-07-07 12-29-11

I have faced this error using the Google Charts in my components, in fact it started happening when I added more than one chart in different components, so GChart was called more than once.

After digging in Google I couldn't find any solution so I read the Google documentation saying that google.chart.load shall be called only once at the begining. Since the module it's doing it by itself, I came out with a solution. I found that I we add the following line before mounting the App it was actually working fine and the error didn't show up.

import { loadGoogleCharts } from 'vue-google-charts'

loadGoogleCharts('current', { packages: ['corechart'] })

Since it looks like a usage problem more than package implementation problem, I would suggest to whoever that maintains the package to update README adding this information. I lost many hours trying to get rid of this issue.

@rexdarelandig
Copy link

jesus. thank you for this. I just added the code in my App.vue

@d4rkmen
Copy link

d4rkmen commented Nov 5, 2024

Excatly the same problem. Thanks for a working solution mr. @Arkk92

@samergoda
Copy link

	methods: {
			displaySideBar(statusDisplay) {
				this.displayMobileSideBar = statusDisplay;
			},
			onMounted() {
				loadGoogleCharts('current', { packages: ['corechart'] });
			},
		},

i added it in app but still have the same error

@Arkk92
Copy link
Author

Arkk92 commented Nov 17, 2024

@samergoda please be careful when reading solutions, you missed the part saying to import it at the beginning. The problem is, loadGoogleCharts() shall be called only once in the whole project. If you put it in onMounted, it's going to be called every time you mount the component.
Try removing the call from there and put it in the main.
Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants