fix: remove delete statement on render for react 18#31
Open
yykoypj wants to merge 1 commit intoreact-component:masterfrom
Open
fix: remove delete statement on render for react 18#31yykoypj wants to merge 1 commit intoreact-component:masterfrom
yykoypj wants to merge 1 commit intoreact-component:masterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
56af391 to
0cf9987
Compare
Codecov Report
@@ Coverage Diff @@
## master #31 +/- ##
==========================================
+ Coverage 98.33% 98.34% +0.01%
==========================================
Files 11 12 +1
Lines 360 363 +3
Branches 98 98
==========================================
+ Hits 354 357 +3
Misses 6 6
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Member
|
@zombieJ 看看? |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解决的问题:
在React18中,在render里面操作delete容易导致意外的情况
问题描述:
在给antd迁移upload的测试库到testing-lib的时候

发现下面的用例修改完语法之后在React18中一直无法通过测试
https://github.com/ant-design/ant-design/blob/master/components/upload/__tests__/uploadlist.test.js#L112-L152
uid为0的记录在删除时一直处在
animate-leave-active的状态调试过程中发现为CSSMotionList在调用CSSMotion组件时传入的onVisibleChange偶尔会变成undifined导致的问题
motion/src/CSSMotionList.tsx
Lines 143 to 159 in 59dc90c
在测试用例中打印下图中的props.onVisibleChange会发现在某一时间点之后成了undefined,导致节点删不掉
motion/src/CSSMotion.tsx
Lines 154 to 159 in 59dc90c
解决方法:
将CSSMotionList.tsx里render中的delete操作替换为不修改原对象的取值操作,测试即可通过