Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useref not defined : error

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>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript generate 3 numbers 1 - 49 
Javascript :: get all the properties of a object in javascript 
Javascript :: javascript radio button onchange 
Javascript :: detect system dark mode javascrip 
Javascript :: mongo query by object id node js 
Javascript :: moment get week 
Javascript :: python json pandas Expected object or value 
Javascript :: loop dictionary with key and value javascript 
Javascript :: setinterval vs settimeout js 
Javascript :: get express variable 
Javascript :: how to call datetime in javascript 
Javascript :: un hover in jquery 
Javascript :: event.target parent 
Javascript :: encode in javascript 
Javascript :: how to change the tab text in React 
Javascript :: how to generate random rgb color number in javascript 
Javascript :: nodejs on exit event 
Javascript :: electron no menu bar 
Javascript :: array contains multiple js 
Javascript :: jquery image change on hover 
Javascript :: laravel 419 
Javascript :: excel datatable 
Javascript :: html string to object jquery 
Javascript :: node es6 import 
Javascript :: react onclick with event 
Javascript :: livewire progress indicators javascript 
Javascript :: zero timeout javascript 
Javascript :: sass config.json vs code 
Javascript :: draw line in javascript 
Javascript :: anchor element onclick not working 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =