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 #208

Open
shanmugarajbe opened this issue Apr 29, 2024 · 8 comments
Open

findDOMNode is deprecated #208

shanmugarajbe opened this issue Apr 29, 2024 · 8 comments

Comments

@shanmugarajbe
Copy link

Hey getting a warning when using the resize-observer,

Screenshot 2024-04-29 at 11 54 56 AM

it's long pending issue and i didn't see any fix?

@teamco
Copy link

teamco commented May 30, 2024

Depends on

import findDOMNode from 'rc-util/lib/Dom/findDOMNode';

....

const getDom = () =>
findDOMNode(elementRef.current) ||
// Support nativeElement format
(elementRef.current && typeof elementRef.current === 'object'
? findDOMNode((elementRef.current as any)?.nativeElement)
: null) ||
findDOMNode(wrapperRef.current);

@kaiyoma
Copy link

kaiyoma commented Oct 2, 2024

Is this going to be fixed? This API is being deprecated by the React folks. If there are no plans to address this, it would be nice to know that now, so we can migrate to a different library.

@afc163
Copy link
Member

afc163 commented Oct 2, 2024

@kaiyoma Could you provide a codesandbox reproduce?

@kaiyoma
Copy link

kaiyoma commented Oct 2, 2024

@afc163 Just use this library along with React 18.3 and you'll get the browser console warning. The React 19 upgrade guide talks about how findDOMNode was deprecated 6 years ago and is finally being removed:

https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-reactdom-finddomnode

@kaiyoma
Copy link

kaiyoma commented Oct 2, 2024

Here's your repro. 😆

import findDOMNode from 'rc-util/lib/Dom/findDOMNode';

@afc163
Copy link
Member

afc163 commented Oct 3, 2024

@kaiyoma Give me a codesandbox and let'me provide a workround for you.

Or you can find it in https://github.com/ant-design/ant-design/pull/51101/files

@kaiyoma
Copy link

kaiyoma commented Oct 3, 2024

Here's a repro: https://codesandbox.io/p/sandbox/finddomnode-forked-4cdsl3?workspaceId=1b72be1a-43a5-4335-8231-c6c61fc1819c

Though I think it's redundant with what you've already posted. (If the child of ResizeObserver is a custom React component, as opposed to a native HTML element, then React will print the console error about findDOMNode.)

@Promisezhangbo
Copy link

我也有一样的问题,期待能早日修复

image
image

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

5 participants