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: style should not be removed when remounted #160

Merged
merged 3 commits into from
Nov 20, 2023
Merged

Conversation

MadCcc
Copy link
Member

@MadCcc MadCcc commented Nov 20, 2023

修复组件重新 mount 时,插入的样式会被延后删除的问题。

事件顺序:

  1. 组件卸载,将清除样式的任务放进下一次的 effect cleanup 中
  2. 组件重新 mount,添加样式,发现 dom 中已存在,所以不会重复添加
  3. 触发 effect cleanup,删除了已有样式,导致样式丢失。

解法:
注销样式前实时判断 cache 中是否存在。

Copy link

github-actions bot commented Nov 20, 2023

🎊 PR Preview 5a04166 has been successfully built and deployed to https://ant-design-cssinjs-preview-pr-160.surge.sh

🕐 Build time: 102.753s

🤖 By surge-preview

@afc163
Copy link
Member

afc163 commented Nov 20, 2023

解决啥原始问题?

@MadCcc
Copy link
Member Author

MadCcc commented Nov 20, 2023

解决啥原始问题?

更新了 PR Body

@MadCcc MadCcc merged commit a9d7e0b into next Nov 20, 2023
6 checks passed
@MadCcc MadCcc deleted the fix/style-removed branch November 20, 2023 13:04
@@ -86,6 +86,8 @@ export default function useGlobalCache<CacheType>(
if (polyfill && times === 0) {
onCacheEffect?.(cacheContent);
}
console.log('times++', times + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console log 没删

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

Successfully merging this pull request may close these issues.

2 participants