USEREF не определено: ошибка
import React, { useEffect, useRef } from "react";
import useWindowSize from "../hooks/useWindowSize";
export default function Player() {
const canvasRef = useRef();
const ctx = useRef();
useEffect(() => {
ctx.current = canvasRef.current.getContext("2d");
}, []);
ctx.current.fillStyle = "green";
ctx.current.fillRect(20, 20, 150, 100);
return (
<React.Fragment
<div>Hello</div>
<canvas ref={canvasRef} width="500" height="500" />
</React.Fragment>
);
}
18BCA058 Vigneshwaran G