Open
Description
maintainer edit: This issue has gotten a little popular, please see a summary of the root cause and workarounds in the below linked comments:
Hey! I'm probably doing something wrong but I can't figure out what...
I have a Next JS app and I have the following object:
"use client";
import { useRef } from "react";
import SignatureCanvas from "react-signature-canvas";
export default function SignaturePad({ onSave }) {
const sigCanvas = useRef(null);
const clear = (event) => {
event.preventDefault();
sigCanvas.current.clear();
onSave(null);
};
const strokeFinished = (event) => {
event.preventDefault();
const dataURL = sigCanvas.current.getTrimmedCanvas().toDataURL("image/png");
onSave && onSave(dataURL); // Send to parent component
};
return (
<fieldset className="fieldset w-full">
<legend className="fieldset-legend">Assinatura</legend>
<div className="border-1 rounded-md input w-full h-[150px] cursor-crosshair">
<SignatureCanvas
ref={sigCanvas}
penColor="black"
onEnd={strokeFinished}
canvasProps={{ className: "w-full h-[150px] rounded-md"}}
/>
</div>
<div className="flex space-x-2">
<button onClick={clear} className="btn btn-primary w-full mt-2">
Limpar
</button>
</div>
</fieldset>
);
}
However, I'm getting this error:
Uncaught TypeError: p is not a function
at e.getTrimmedCanvas (145-1f8f2f744481203b.js:1:12839)
at f.onEnd (page—-dda8c99f385158aa.js:1:2153)
at f._strokeEnd (145-1f8f2f744481203b.js:1:6137)
at HTMLCanvasElement._handleTouchEnd (145-1f8f2f744481203b.js:1:3327)

Does anyone know how to fix this? Thanks!