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

Fix motion warning of findDOMNode #51

Merged
merged 6 commits into from
May 16, 2024
Merged

Fix motion warning of findDOMNode #51

merged 6 commits into from
May 16, 2024

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented May 15, 2024

fix #50

缘由

motionDeadline 会在 active 态一下增加一个计时器,当时间到时则触发一次 fallback motionEnd 事件。motionEnd 事件会检测当前的动画状态是否是 Appear or Enter or Leave 之一。当 DOM 元素的动画被正确触发时,由于 status 被重置为 none 所以会跳过兜底事件。

但是虽然事件会跳过,获取 DOM 元素的检测还是在逻辑中的。这导致了 DOM 被删除后被降级为 findDOMNode ,从而触发了 React warning。

修复方式

在使用 getDOM 的地方提前检测一下 status 是否是 none,如果已经是了则直接跳过。提前进行短路。

Copy link

vercel bot commented May 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
motion ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 2:40am

@li-jia-nan
Copy link
Member

Vercel 顺便修一下吗大佬

@zombieJ zombieJ merged commit 9f60865 into master May 16, 2024
7 checks passed
@zombieJ zombieJ deleted the fix-motion-warn branch May 16, 2024 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants