Pomax / react-onclickoutside

An onClickOutside wrapper for React components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mykas opened this issue · 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
facebook/react#14188 (comment)

It seems it is related to usage under React.Suspense

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.

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

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