Javascript newbie here^^
In my React front, I have the following chrome error message :
Unhandled Rejection (TypeError): Cannot read property 'style' of null
▶ 2 stack frames were collapsed.
new LiquidFillGauge
SOMEPATH/liquidFillGauge.tsx:46
43 | var gauge = d3.select('#' + elementId);
44 | var radius = 0, locationX = 0, locationY = 0;
45 | if (gauge != null && gauge != undefined) {
> 46 | radius = Math.min(parseInt(gauge.style('width')), parseInt(gauge.style('height'))) / 2;
47 | ^ locationX = parseInt(gauge.style('width')) / 2 - radius;
48 | locationY = parseInt(gauge.style('height')) / 2 - radius;
49 | }
gauge being exceedingly checked in line 45, it still appears null in line 46.
Why is that happening ? How could I avoid the error ?
Thank you