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

Unable to get property 'getCursorPosition' of undefined or null reference #24

Open simeonpashley opened 6 years ago

simeonpashley commented 6 years ago

When using v2.5.0, I see numerous entries in Sentry with the same error report. I haven't used previous versions so I don't know if this is a new issue.

Unable to get property 'getCursorPosition' of undefined or null reference

In the code excerpt below, it implies that this.core is null/undefined

            this.schedulActivation(this.props.hoverDelayInMs);
        }
    }, {
        key: 'onMouseMove',
        value: function onMouseMove(e) {
            this.setPositionState(this.core.getCursorPosition(e));
        }
    }, {
        key: 'onMouseLeave',
        value: function onMouseLeave() {
            this.clearActivationTimers();

All the issues seem to be IE11 / Edge.... https://sentry.io/share/issue/b315166598af4d818172fd34cf2508db/ https://sentry.io/share/issue/4e135f3320604ae88d31a56f503906d7/ https://sentry.io/share/issue/b2a9bcd3f7144fe5b0f15cd1b5a2f81f/

ethanselzer commented 6 years ago

Hi @simeonpashley - Thanks for reporting this issue. I released a possible fix in version 2.5.1-0. Please try it by installing react-cursor-position@2.5.1-0. In case you are interested, the branch with the changes is named issue24. Please let me know your findings. ~Ethan

simeonpashley commented 6 years ago

Thanks, I'll give that a try.

FYI I'm using a component react-image-magnify, which uses your component

ethanselzer commented 6 years ago

Thank you for trying version 2.5.1-0. I appreciate it.

I had a look at react-image-magnify. It seems like it specifies version 2.4.1 of react-cursor-position. I'm wondering if you know why you have react-cursor-position@2.5.0

ethanselzer commented 6 years ago

@simeonpashley - I am able to reproduce the issue you identified in Windows Edge. I think it is corrected in v3.0.0. Thanks again for bringing it to my attention. I appreciate it!

ethanselzer commented 6 years ago

Anyone experiencing the "Unable to get property 'getCursorPosition' of undefined or null reference" issue in MS Edge, and also want the v2.x API, you can try v2.5.3.

ethanselzer commented 6 years ago

@simeonpashley - Thanks again for opening this issue. I'm closing it as fixed in latest and v2.5.3. Please let me know if you don't think it has been corrected.

kimsangw commented 5 years ago

@ethanselzer Hi, I got this error from Sentry with v3.0.3

ReactCursorPosition.js:164 Uncaught TypeError: Cannot read property 'getCursorPosition' of undefined
   at t.value (ReactCursorPosition.js:164)
ethanselzer commented 5 years ago

Hi @kimsangw - Thanks for the information. Do you know if Sentry can provide details about the browser/OS? Also is there a high rate of this error?

kimsangw commented 5 years ago

@ethanselzer there isn't any details about the browser but the rate of error is low.

ethanselzer commented 5 years ago

@kimsangw - Thanks for following up. I will investigate.

vincentdesmares commented 4 years ago

Hi @ethanselzer, sentry is sending at least one time per day this error. I was also thinking is was an IE-only bug, but the last report was for Chrome. Here is the details about the user:

Browser: Chrome 81.0.4044 browser.name: Chrome device: Mac device.family: Mac os: Mac OS X 10.11.6 os.name: Mac OS X url: https://teamstarter.co/

The code breaks here:

    });
    }
  }, {
    key: 'onClick',
    value: function onClick(e) {
      this.setPositionState(this.core.getCursorPosition(e)); <--- HERE
      this.mouseActivation.mouseClicked();
      this.onMouseDetected();
    }
  }, {
    key: 'onTouchDetected',