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

[Tree] React 18.3 已弃用 findDOMNode #2897

Open
duxphp opened this issue May 14, 2024 · 2 comments
Open

[Tree] React 18.3 已弃用 findDOMNode #2897

duxphp opened this issue May 14, 2024 · 2 comments
Labels
need more info 需要更多信息理解 issue 的问题 react19

Comments

@duxphp
Copy link
Contributor

duxphp commented May 14, 2024

tdesign-react 版本

1.17.0

重现链接

No response

重现步骤

使用 react 18.3+依赖,则直接提示 Warning: findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference.

期望结果

弃用 findDOMNode 依赖

实际结果

findDOMNode 与react18 不兼容

框架版本

react(18.3)

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

Copy link
Contributor

👋 @duxphp,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@NWYLZW NWYLZW added the need more info 需要更多信息理解 issue 的问题 label May 14, 2024
@NWYLZW
Copy link
Collaborator

NWYLZW commented May 14, 2024

  • 不是不兼容,React 19 才不兼容,现在只是警告
  • 现在已经处理过了,并不是 tdesign 引入的,请提供可以复现的 sandbox

/* ======== render ======= */
// https://github.com/reactjs/react-transition-group/issues/668
// CSSTransition 不指定 nodeRef 的时候会使用 findDOMNode 获取 dom
// 因为 CSSTransition 是个数组,与 visibleNodes 对应,所以这里根据 visibleNodes 的长度创建 ref 用来保存 dom
// visibleNodes 改变的时候,释放上一个 nodeList,防止内存泄漏
const nodeList = useMemo<RefObject<HTMLDivElement>[]>(
() => visibleNodes.map(() => React.createRef()),
[visibleNodes],
);

@NWYLZW NWYLZW added the react19 label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info 需要更多信息理解 issue 的问题 react19
Projects
None yet
Development

No branches or pull requests

2 participants