fix: update refs handling in RickGamePanel for improved canvas access

This commit is contained in:
Chipperfluff 2025-07-20 15:18:12 +02:00
parent a897853426
commit e2d9aa60b4

View File

@ -1,6 +1,7 @@
import { h, render, Component } from 'nano-jsx'
class RickGamePanel extends Component {
refs: { [key: string]: any } = {}
canvas?: HTMLCanvasElement
ctx?: CanvasRenderingContext2D
x = 20
@ -59,13 +60,14 @@ class RickGamePanel extends Component {
}
mounted() {
this.canvas = this.ref('game') as HTMLCanvasElement
this.canvas = this.refs['game'] as HTMLCanvasElement
this.ctx = this.canvas?.getContext('2d') || undefined
this.canvas?.addEventListener('click', this.handleJump)
this.frame()
}
render() {
return (
<div