findDOMNode is deprecated
Hey getting a warning when using the resize-observer,
it's long pending issue and i didn't see any fix?
Depends on
import findDOMNode from 'rc-util/lib/Dom/findDOMNode';
....
const getDom = () =>
findDOMNode<HTMLElement>(elementRef.current) ||
// Support nativeElement format
(elementRef.current && typeof elementRef.current === 'object'
? findDOMNode<HTMLElement>((elementRef.current as any)?.nativeElement)
: null) ||
findDOMNode<HTMLElement>(wrapperRef.current);
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.
@kaiyoma Could you provide a codesandbox reproduce?
@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
Here's your repro. 😆
https://github.com/react-component/resize-observer/blob/1ab2eec393d51262855ef1cf8fa94f6cc3139a82/src/SingleObserver/index.tsx#L1
@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
-
findDOMNode is deprecatedreproduce: https://codesandbox.io/p/sandbox/finddomnode-c5hy96 - Using
forwardRefto fix: https://codesandbox.io/p/sandbox/no-finddomnode-warning-forked-gdxczs
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.)
我也有一样的问题,期待能早日修复