Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
TypeError: sigCanvasRef.getTrimmedCanvas is not a function

I get the error above when using getTrimmedCanvas. I read that when using a background style this error occurs because it needs a white background or something like that.

Theres more code but i only pasted the relevant stuff.

Thank you for helping!

import Popup from "reactjs-popup";
import SignaturePad from "react-signature-canvas";

export default function Homepage() {

    const sigCanvasRef = useRef({});

    const clear = () => sigCanvasRef.current.clear();

const save = () =>
   console.log(sigCanvasRef.getTrimmedCanvas().toDataURL("image/png"))

return(
<Popup modal trigger={<Button style={{ maxWidth: '40px', maxHeight: '40px', minWidth: '40px', minHeight: '40px' }} color="inherit">
<CreateIcon />
</Button>}
closeOnDocumentClick={false}
>
{close => (
    <>
        <div className={sigCanvas.signatureCanvas} >
            <SignaturePad
                ref={sigCanvasRef}
                canvasProps={
                    {
                        style: {background: 'white', width:'100%', minHeight:'650%'}
                    }
                } />
        </div>
        <Button variant="contained" onClick={close}>back</Button>
        <Button variant="contained" onClick={clear}>clear</Button>
        <Button variant="contained" onClick={save}>save</Button>
    </>
)}

</Popup>
)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You access refs by the current-property.

Try this

console.log(sigCanvasRef.current.getTrimmedCanvas().toDataURL("image/png"))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!