react-onclickoutside icon indicating copy to clipboard operation
react-onclickoutside copied to clipboard

onClickOutside internal method findDomNode sometimes throws error not able to find the DOM Node.

Open mykas opened this issue 6 years ago • 4 comments

In certain cases this methods throws an error not finding the Dom. It seems it is related to React and it was fixed in react 16.9.0. Dan from React suggests moving away from findDomNode method as it will be deprecated anyway.

https://github.com/Pomax/react-onclickoutside/blob/master/src/index.js#L100 https://github.com/facebook/react/issues/14188#issuecomment-516542593

mykas avatar Aug 23 '19 08:08 mykas

It seems it is related to usage under React.Suspense

mykas avatar Aug 23 '19 12:08 mykas

Same issue here.. Using React.Lazy & Suspense to lazy load some components. While loading/downloading these I show a Loading component. This unmounts all other components I suppose and the setState trigger onClickOutside wouldn't work.

tried the isUnmounted approach but no success

`componentWillUnmount() { this.isUnmounted = true; }

handleClickOutside = () => { if(!this.isUnmounted) { this.setState({ dropDownOpen: false }); } } `

Please let me know if anyone have a solution.

moparlakci avatar Nov 19 '19 22:11 moparlakci

We do have a solution but we will need to do a breaking change version to migrade our clickoutside infrastructure/

mykas avatar Nov 20 '19 07:11 mykas

This is blocking us from moving to lazy imports. Please try if your solution solves the issue.

akash-rajput avatar Aug 04 '20 10:08 akash-rajput