woutervh-/react-pan-and-zoom-hoc

componentRef.current.addEventListener is not a function in React 16.5

zrisher opened this issue · 3 comments

I receive TypeError: this.componentRef.current.addEventListener is not a function when attempting the Unmanaged Example from the Readme while using React 16.5.

The error is thrown from panAndZoomHoc.tsx#L75

if (this.componentRef.current) {
  this.componentRef.current.removeEventListener('wheel', this.handleWheel);
}

Using Chrome debugger, it appears this.componentRef.current returns the component itself and not a DOM reference:

image

Purportedly we're supposed to use ReactDOM.findDOMNode(component) to get the DOM reference from a component.

Hi @zrisher
Good point, I forgot about wrapped React components.
I will fix it and release a new version, in the meantime version 1.4.1 still uses the old findDOMNode method and should work just fine.

Thanks

I also update the major version 2 so you can also use 2.0.1 now.
Let me know if it works for you.

@woutervh- Thanks for the quick response. You are correct, 1.4.1 works just fine. I don't see 2.0.1 up on NPM but will switch over asap. Thank you!