ethanselzer / react-cursor-position

A React component that decorates its children with mouse and touch coordinates relative to itself.
https://ethanselzer.github.io/react-cursor-position
MIT License
143 stars 35 forks source link

Compatibility with React 16 #31

Open davidhatten opened 5 years ago

davidhatten commented 5 years ago

One of the minor versions of React 16 (I think, 16.2?) changed the typeof response from function to object. This causes the method getIsReactComponent(reactElement) to return false, thereby causing the intended wrapped element to not have the position properties not added to its props.

carpiediem commented 4 years ago

@davidhatten are you aware of any way to avoid this issue, until this library gets updated? Or do I need to (a) hold off on updating react or (b) find an alternative to react-cursor-position?

davidhatten commented 4 years ago

@carpiediem I yanked it out of my project for the time being and manually implemented the functionality I needed. Not sure what you're doing, but I grabbed the x and y position from the event and then had to do some SVG handling.

https://github.com/davidhatten/geometric-drawer/blob/master/webpack/containers/Canvas.js#L23

carpiediem commented 4 years ago

Got it, thanks. Not too hard for position