Chartjs-React and chart.js with json

0👍

try moving the execution this.funDadosGrafico() and Canvas creation to componentDidUpdate.

once you call fetch, fetch wont block the thread, hence this.funDadosGrafico() is executed right aftwards. then blocks are executed only after fetch is resolved.

plus, setState method is also async. it is not going to work as expected even if you remove setState from fetch call like:

this.setState(updateMyState)
this.funDadosGrafico() // not going to work also, setState is async

Leave a comment