Pomax / react-onclickoutside

An onClickOutside wrapper for React components
MIT License
1.82k stars 187 forks source link

The use of findDOMNode is deprecated in React Strict Mode #315

Closed arqex closed 5 years ago

arqex commented 5 years ago

Hey! First thanks for this great library I've been using for so long.

It is used also inside of react-datetime and I got an issue from a user complaining about using reactDom.findDOMNode. Looks that it's going to be deprecated and we should move away from it.

Any alternative for removing it?

Cheers

Pomax commented 5 years ago

Does the warning tell you what should be used instead, by any chance?

NamespaceValentine commented 5 years ago

The docs suggest using refs: https://reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage

This fix is pertinent because strict mode is required for upcoming React features such as Concurrent Mode, thus this will not work properly unless it is refactored.

Pomax commented 5 years ago

given how this HOC works, refs are a problem until it's uplifted to use forwardRefs, so it might keep throwing warnings until we can get to updating it with those =(

(but if you want to take a stab at it, that'd be aweseme!)

NamespaceValentine commented 5 years ago

The main issue as I posted above, is that warnings now will become errors when this is used with upcoming react features.

Pomax commented 5 years ago

But React follows proper semver, and do not release minor versions that are backward incompatible. Those warnings will not turn into errors until React 17, at which point v6 of this library will become incompatible (just like how v5 is incompatible with versions before v15).

I'm not saying this shouldn't get fixed, but I am saying that warnings are not errors, and this library will keep working with the main React component pattern just fine until that next major release comes out. So until then: if you want to take a stab at it, that's great, but I probably won't get to addressing this myself until I can find some time from my other engagements (or if someone pays me to make time and do this sooner, of course. I only have a finite amount of time, and quite a lot of projects).

Pomax commented 5 years ago

v6.9.0 published

alpepe commented 3 years ago

Hello, I see that the issue is closed, but I still notice it with me even though I up react-onclickoutsideit to version 6.10.0

"Warning: findDOMNode is deprecated in StrictMode...."

Pomax commented 3 years ago

was that a typo, or are you actually using something called react-onclickoutsideit? (because that would be a different project, then)

alpepe commented 3 years ago

Typo, sorry, what I'm using is "react-onclickoutside": "^6.10.0" exactly. And I still have the Warning "findDOMNode is deprecated in StrictMode..." when I wrapped onClickOutside in "React Strict Mode"

Pomax commented 3 years ago

Then you'll want to file a new issue, since this one got closed, with a minimum reproducible example so the problem's essentially reproducible with a copy paste. Thanks!

brandondurham commented 3 years ago

I see no newer issue. Was this resolved?

Pomax commented 3 years ago

I didn't see a new issue filed, so not yet