import { Canvas, painters } from 'headbreaker-ts';
import { useEffect, useRef } from 'react';
function DemoPuzzle({ id }) {
const puzzleRef = useRef(null)
const puzzle = puzzleRef.current
const canvas = new Canvas(puzzle.id, {
pieceSize: 100, proximity: 20,
borderFill: 10, strokeWidth: 2, lineSoftness: 0.18,
painter: new painters.Konva()
// ^ this is important — see
// https://github.com/ShadowNineX/headbreaker/issues/51
horizontalPiecesCount: 2,
return <div ref={puzzleRef} id={id}></div>
export default function Home() {
<h1>Headbreaker From React</h1>
<DemoPuzzle id="puzzle" />