preactjs / preact-compat

ATTENTION: The React compatibility layer for Preact has moved to the main preact repo.
http://npm.im/preact-compat
MIT License
949 stars 148 forks source link

ReactDOM.findDOMNode does not really work in ref callback #429

Closed abrenneke closed 5 years ago

abrenneke commented 7 years ago

My react project uses react-click-outside for outside click detection. It does a rather idiosyncratic:

ref={c => {
  this.__wrappedInstance = c;
  this.__domNode = ReactDOM.findDOMNode(c);
  wrappedRef && wrappedRef(c);
}}

Which works in react, but plugging in preact-compat causes the component itself to be assigned to this.__domNode (because this.base is undefined), not the dom node it's expecting, and further down the line it errors.

Not really sure who's at fault here, but I figure if it works in React and not in Preact, something's up.

marvinhagemeister commented 5 years ago

This is fixed in Preact 10. Make sure to use preact/compat instead of preact-compat.