Chartjs-Type Error in react & react-chartjs2 (Argument of type 'undefined' is not assignable to β€”)

0πŸ‘

the solution have been found
i genrally use any type in useRef so it can acquire any type of refrences
so the code becomes

const chartRef = useRef<any>(); //just use any type here and problem resolved
const onClick = (e:React.MouseEvent<HTMLCanvasElement, MouseEvent>) => {
  console.log(getDatasetAtEvent(chartRef.current, e));
}

Leave a comment