FabriPetrelli
Posts: 14
Joined: Thu Nov 12, 2020 9:39 am

Update from state (React)

Hi guys,

I'm trying to have a map component that I can update with different maps from a call to an API that return a JSON file,
for now I'm struggling with the update of the map, let me explain:

-The map data is from a file that I've downloaded and imported in my project, for now I only want to have two buttons, one that inserts the data of the map into the specified path and another one for cleaning it.

If I console.log the path the function to insert the data works and also the one to clear it but no maps are viewed.

If I directly put the file in the properties of the component without using the state the map is visualized so there is no problem with the file.

Any help would be appreciated!

Here's my code on stackblitz:
https://stackblitz.com/edit/react-by7qq ... src/App.js
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Update from state (React)

Hello FabriPetrelli!

Welcome to our forum and thanks for contacting us with your question!

I've checked your demo and noticed that you did not add any data. That's why the chart is not displayed. When you add any data while adding the map then it works fine. :)

Check out the demo: https://stackblitz.com/edit/react-y8s8c ... src/App.js

Let me know if that was what you were looking for!
Best regards.
Dominik Chudy
Highcharts Developer
FabriPetrelli
Posts: 14
Joined: Thu Nov 12, 2020 9:39 am

Re: Update from state (React)

dominik.c wrote: Thu Nov 12, 2020 12:16 pm Hello FabriPetrelli!

Welcome to our forum and thanks for contacting us with your question!

I've checked your demo and noticed that you did not add any data. That's why the chart is not displayed. When you add any data while adding the map then it works fine. :)

Check out the demo: https://stackblitz.com/edit/react-y8s8c ... src/App.js

Let me know if that was what you were looking for!
Best regards.

Yes, now works perfectly!
Thank you very much.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Update from state (React)

You're welcome!
The truth is you did all the job. Congrats! :)

In case of any further questions, feel free to contact us again.
Dominik Chudy
Highcharts Developer

Return to “Highcharts Maps”