resize-observer icon indicating copy to clipboard operation
resize-observer copied to clipboard

findDOMNode is deprecated

Open shanmugarajbe opened this issue 1 year ago • 8 comments

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?

shanmugarajbe avatar Apr 29 '24 06:04 shanmugarajbe

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);

teamco avatar May 30 '24 12:05 teamco

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 avatar Oct 02 '24 02:10 kaiyoma

@kaiyoma Could you provide a codesandbox reproduce?

afc163 avatar Oct 02 '24 02:10 afc163

@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 avatar Oct 02 '24 19:10 kaiyoma

Here's your repro. 😆

https://github.com/react-component/resize-observer/blob/1ab2eec393d51262855ef1cf8fa94f6cc3139a82/src/SingleObserver/index.tsx#L1

kaiyoma avatar Oct 02 '24 19:10 kaiyoma

@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

afc163 avatar Oct 03 '24 02:10 afc163

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.)

kaiyoma avatar Oct 03 '24 03:10 kaiyoma

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

image image

Promisezhangbo avatar Nov 12 '24 09:11 Promisezhangbo