michaeldzjap / react-signature-pad-wrapper

A React wrapper for signature pad
MIT License
205 stars 27 forks source link

onEnd and onBegin doesn't not fire #3

Closed ultrox closed 6 years ago

ultrox commented 6 years ago

I was trying to trigger some behaviour by passing function to onEnd hook, this hook dont want to fire. Am I doing something wrong?

Basically I was trying to save the data to a state after user ends writing on the canvas.

function handleOnEnd() {
    console.log('never fire')
}
    <SignaturePad
        value={props.value}
        onEnd={handleOnEnd}
        ref={ref => (this.signaturePad = ref)}
        options={{}}
      />
michaeldzjap commented 6 years ago

@ultrox the onEnd and onBegin hooks are _signaturepad specific options. Hence, you need to specify them as part of the options property instead of having them as a direct property of the SignaturePad component. So this should do what you'd expect:

function handleOnEnd() {
    console.log('never fire')
}
...
<SignaturePad
    ref={ref => (this.signaturePad = ref)}
    options={{onEnd: handleOnEnd}} />
ultrox commented 6 years ago

@michaeldzjap I though this might be it, but I end up assigning onEnd to instnace directly in lifecycle method, but I like your solution much better. Thanks Michael!

shahriarhossain commented 1 year ago

@michaeldzjap : I am calling the onEnd handler from within the options like this: image

But for some reason its not getting triggered. I am using "react-signature-pad-wrapper": "^3.3.1"

michaeldzjap commented 1 year ago

@shahriarhossain onEnd no longer exists in v4 of signature pad. See #36 and this.