Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findDOMNode is deprecated in StrictMode #71

Open
palagonKevo opened this issue Dec 28, 2023 · 0 comments
Open

findDOMNode is deprecated in StrictMode #71

palagonKevo opened this issue Dec 28, 2023 · 0 comments

Comments

@palagonKevo
Copy link

I've been facing this warning for a lot of time. Everything works fine, but it keeps saying that it's deprecated. I've been diving into the code to find the current issue and I found out that the problem has to be with the react-draggable dependency that it's used within this project.

To be more precise, the file that is having issues with is /src/components/RangeBox.tsx., in which the draggable library is used. I've been also looking at the library's code in order to find a solution and I found out that in their changelog files they have already contemplated this issue, and they have provided a solution to it.

Down is the text that they have written about this:

4.4.0 (May 12, 2020)

  • Add nodeRef:
    • If running in React Strict mode, ReactDOM.findDOMNode() is deprecated.
      Unfortunately, in order for <Draggable> to work properly, we need raw access
      to the underlying DOM node. If you want to avoid the warning, pass a nodeRef
      as in this example:
      function MyComponent() {
        const nodeRef = React.useRef(null);
        return (
          <Draggable nodeRef={nodeRef}>
            <div ref={nodeRef}>Example Target</div>
          </Draggable>
        );
      }

Would it be possible to fix this? The solution itself is quite easy as it only requires adding a prop with the ref variable as stated in the example provided by the developers.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant