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

Support React 19 – Replace findDOMNode (Removed in React 19)

Open mitul-birdeye opened this issue 8 months ago • 3 comments

With the release of React 19 as the new LTS version, it would be great if this package could officially support React 19. Currently, when attempting to use this package in a React 19 project, the following error is thrown:

Image

This is due to the removal of findDOMNode from the React DOM package in React 19.

To ensure compatibility with React 19, it would be helpful to replace findDOMNode with an alternative. Would it be possible to update the package to support this change? Happy to help if needed!

Thanks!

mitul-birdeye avatar Apr 15 '25 09:04 mitul-birdeye

Did you read https://github.com/Pomax/react-onclickoutside?tab=readme-ov-file#functional-component-with-usestate-hook first?

Pomax avatar Apr 16 '25 19:04 Pomax

The reason it would still be useful is packages which:

  1. use this one as a dependency;
  2. don't release new versions anymore, so they won't follow this advice;
  3. would still be usable with React 19 otherwise because they don't use findDOMNode, legacy context, etc.

I don't have any examples at the moment, because the ones in my project violate 3 and will need to be replaced anyway, but I expect there still are some.

alexeyr-ci2 avatar Jun 08 '25 07:06 alexeyr-ci2

I'm fine with people taking ownership of their own libraries, too, though. Time has moved on, if you're in a situation where (1) and (2) apply, the solution is to either also move on and find a new library that does what you need, or to patch that dependency yourself so it no longer depends on this one.

This codebase doesn't need to keep getting updated, unless (and that's been the case for years now) someone wants to pay for that work to happen. Then I'll be happy to uplift this project to work with current React.

Pomax avatar Jun 13 '25 15:06 Pomax

To the downvoters, who are unlikely to see this: free software isn't free to author. If you want a feature bad enough, I'll be happy to put it in for fair pay, but otherwise this is a "you don't need this library to do what you want in modern React, just write the hook you need and it'll be less code, and one fewer supply chain poisonable dependency".

Especially given the number of times NPM has been compromised this year alone.

Before you reach for yet another dependency: if it takes less than 100 lines of code to just write it yourself, just write it yourself.

Pomax avatar Sep 19 '25 00:09 Pomax