ant-design / cssinjs

https://ant-design.github.io/cssinjs
MIT License
236 stars 59 forks source link

fix: style should regenerate when remounted #124

Closed MadCcc closed 11 months ago

MadCcc commented 11 months ago

由于新渲染的组件 render 阶段要比旧组件的 unmount 阶段更早,所以在 react 17 以下会出现先插入新组件的 style 标签,再执行旧组件的卸载,最后执行新组件的 mount,计数+1。在旧组件卸载时计数实际上还没有增加,所以就回触发删除逻辑。 ref: https://codesandbox.io/s/aged-cdn-qjxmpz?file=/src/App.tsx

github-actions[bot] commented 11 months ago

😭 Deploy PR Preview 542d569d8c2b9976ff7bef5ca3e4df0ba7a7997b failed. Build logs

🤖 By surge-preview

codecov-commenter commented 11 months ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 :tada:

Comparison is base (2470fec) 96.25% compared to head (ba5ff8c) 96.29%.

:exclamation: Current head ba5ff8c differs from pull request most recent head 542d569. Consider uploading reports for the commit 542d569 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #124 +/- ## ========================================== + Coverage 96.25% 96.29% +0.03% ========================================== Files 23 23 Lines 1791 1810 +19 Branches 299 302 +3 ========================================== + Hits 1724 1743 +19 Misses 67 67 ``` | [Impacted Files](https://app.codecov.io/gh/ant-design/cssinjs/pull/124?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) | Coverage Δ | | |---|---|---| | [src/hooks/useCacheToken.tsx](https://app.codecov.io/gh/ant-design/cssinjs/pull/124?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2hvb2tzL3VzZUNhY2hlVG9rZW4udHN4) | `99.39% <100.00%> (+0.01%)` | :arrow_up: | | [src/hooks/useCompatibleInsertionEffect.tsx](https://app.codecov.io/gh/ant-design/cssinjs/pull/124?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2hvb2tzL3VzZUNvbXBhdGlibGVJbnNlcnRpb25FZmZlY3QudHN4) | `100.00% <100.00%> (ø)` | | | [src/hooks/useGlobalCache.tsx](https://app.codecov.io/gh/ant-design/cssinjs/pull/124?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2hvb2tzL3VzZUdsb2JhbENhY2hlLnRzeA==) | `96.55% <100.00%> (+0.21%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.