SolidJSS
SolidJSโ€ข3y agoโ€ข
1 reply
Liquido

How can I use SolidJS ref with typescript?

I want to create a ref to a canvas element:

export const Canvas = () => {
  let ref: HTMLCanvasElement;

  return <canvas ref={ref} width={500} height={500}></canvas>;
};


But I keep getting TS error that "Variable ref is being used without being assigned." What's the correct way to use refs with Typescript?
Was this page helpful?