0

Does anyone has experience in using SignaturePad in React?

I realise that the example is using DOM which I can try to replicate with Ref in react, but it doesn't seem very natural and I can't see any example online of using it in React.

Can anyone help?

Thanks

DevBF
  • 247
  • 4
  • 15

2 Answers2

3

If you are looking for a library that you want to integrate with React application then you can check out this React Component Wrapper around Signature Pad. Hope this helps.

Nithish
  • 5,393
  • 2
  • 9
  • 24
2

The way to access DOM in react is using Refs

You can either use React.createRef() or use React hooks with useRef

Then you can call your ref to the canvas like this:

const myRef = useRef(null);

useEffect( () => { myRef.current.doSomething() });

return(
  <canvas ref={myRef}> </canvas>
)
Robert Tirta
  • 2,593
  • 3
  • 18
  • 37