react-skinview3d
react-skinview3d copied to clipboard
TypeError: g is undefined in a NextJS project
When trying to use the library in a Next project, the type error occurs
Sandbox: https://codesandbox.io/p/devbox/trtrms
Me doing this fixed the issue, maybe this helps :)
"use client"
import React, { useEffect } from "react"
import { SkinViewer } from "skinview3d"
export default function PlayerViewer({ uuid }: { uuid: string }) {
const canvasRef = React.useRef<HTMLCanvasElement>(null)
useEffect(() => {
if (!canvasRef.current) {
return
}
const viewer = new SkinViewer({
canvas: canvasRef.current,
width: 500,
height: 500,
})
viewer.loadSkin(`https://www.mc-heads.net/skin/${uuid}`)
}, [canvasRef])
return <canvas ref={canvasRef} />
}
Should be related to https://github.com/Hacksore/react-skinview3d/pull/167