1// If this helps, don't forget to upvote so others see this.
2
3// install the following dependencies with npm in terminal for this to work.
4// npm i react-signature-canvas
5// npm i react-signature-pad
6
7import React, {useRef} from 'react';
8import SignaturePad from 'react-signature-canvas';
9
10export default function MySignaturePad () {
11
12 let padRef = useRef({})
13
14 function handleClear () {
15 padRef.current.clear();
16 }
17
18 return (
19 <div>
20 <SignaturePad
21 ref={padRef}
22 backgroundColor='#F4F4F4'
23 />
24 <button
25 onClick={() => {handleClear()}}
26 >
27 Clear
28 </button>
29 </div>
30 )
31}