agilgur5 / react-signature-canvas

A React wrapper component around signature_pad (in < 150 LoC). Unopinionated and heavily updated fork of react-signature-pad
https://agilgur5.github.io/react-signature-canvas/
Other
547 stars 119 forks source link

Placing a single dot throws an error #11

Closed kgram closed 6 years ago

kgram commented 7 years ago

Clicking the canvas without dragging throws an error. I believe this to be caused by this line. The default value for dotSize is defined as an arrow-function, using this to access props. However, the function is defined staticly, which means there is no this to speak of. Babel transforms the line to

return ((void 0).props.minWidth + (void 0).props.maxWidth) / 2

The result is Uncaught TypeError: Cannot read property 'props' of undefined.

There is a pull request attempting to fix this, but unfortunately it basically just hardcodes the default dotSize to 2.

Perhaps passing the minWidth and maxWidth to the dotSize-function could be a solution?

agilgur5 commented 7 years ago

Ahh that's what the problem was with that function -- great catch @kgram !!

That change would not be backward compatible (would require a major release as per semver), but I believe that would be most optimal, especially as that would make it easier for anyone passing in a dotSize function as a prop to just use arguments.

Indigo744 commented 7 years ago

Any update on this ?

indiejoseph commented 7 years ago

+1

agilgur5 commented 6 years ago

resolved by #8