-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[BUG] antd Descriptions component, Inconsistency between props
and children
when using ArraySetter
#2177
Comments
这里的 ths.state.arr 是写错了还是故意设置成这样的? |
故意的,实际上设置其他的值也可以,只要 在 #2172 这个问题被修复之前,可以通过这个方式来主动触发一个报错,进而通过这个报错来展示出 而我之所以选择这个报错,是因为我尚且不知道有没有其他的主动触发报错的方式 |
不是,这里应该是 this.state.arr,而不是 ths,这样导致这个语句的判断出现了问题。
|
噢😯 那确实是我写错了。。已修正 |
那再确定一下,这个问题是否还存在。我配置了正确的 this.state.arr && this.state.arr.length 条件语句之后,报错就没有了。 |
问题存在。我想了一下,我们可以换一个简单的方式 en ver:
cn ver:
第5步之后应当会得到 |
这个问题应该和 Descriptions 组件的配置应该有关系,它在 items 变化的时候,才会同步 items 下的 Slot,可以看到: 1.在第 4 步(在这个新元素中添加 Typography.Text 组件)的时候,大纲树是这样的 2.在第 6 步(在 列表项 中添加一个新元素并删除)的时候,大纲树是这样的 所以相当于这里的 items 添加或者删除的时候才会将改动正确同步。可以在 https://github.com/alibaba/lowcode-materials 看一下相关组件的配置。 |
props
and children
when using ArraySetter
props
and children
when using ArraySetter
Describe the bug (required) / 详细描述 bug(必填)
When settings a component's prop via
ArraySetter
, in schema the component'sprops
andchildren
can be different which may cause problems.当通过
ArraySetter
设置物料组件的一个属性时,schema 中组件的props
和children
有可能会不一样,这有可能会产生问题。To Reproduce (required) / 如何复现 bug?(必填,非常重要)
Steps to reproduce the behavior: / 详细复现步骤:
en ver:
Descriptions
componentitems
Typography.Text
componentloop data
of the text component tothis.state.arr
and set thecontent
to bind variablethis.item.name
items
and then delete itcondition
of the text component tothis.state.arr && this.state.arr.length > 0
items
cn ver:
描述列表
组件列表项
中添加一个新元素Typography.Text
组件循环数据
为this.state.arr
,并设置内容
为变量绑定this.item.name
列表项
中添加一个新元素并删除是否渲染
为this.state.arr && this.state.arr.length > 0
列表项
中添加一个新元素Expected behavior (required) / 预期行为(必填,非常重要)
The content in
props
andchildren
should be the same throughout the whole operation, exceptid
.全操作流程中
props
和children
内除id
外其他内容保持一致Additional context (optional) / 更多额外信息(可选)
props
andchildren
are the same. / 步骤3、步骤6和步骤8之后,props
和children
是一致的Typography.Text
exists inchildren
but doesn't exist inprops
. / 步骤4之后,children
有Typography.Text
但是props
里没有props
andchildren
are different / 步骤7之后,props
和children
是不一致的The inconsistency of
props
andchildren
causes a problem in above operation:TypeError: Cannot read properties of undefined (reading 'name')
in preview page (this is by design, we can use other errors as example)children
toprops
viaArraySetter
because we modifyitems
condition
, the error still exists in preview pageitems
again (by adding a new item) to syncchildren
toprops
I don't know the reason, but it seems that the errors will disappear when both
props
andchildren
are ok. If the user don't check schema, he cannot know that he need to modifyitems
again to fix the errors.这个
props
和children
之间的不一致有可能造成一个问题:TypeError: Cannot read properties of undefined (reading 'name')
(故意的,我们也可以用其他错误来举例子)列表项
,我们通过ArraySetter
将children
同步到了props
是否渲染
,预览页面中错误仍然存在列表项
来同步children
到props
我不清楚原因,似乎只有在
props
和children
都没问题之后报错才会消失。如果用户不曾检查过 schema,他不可能知道他需要修改一下列表项
来修复报错The error mentioned above is related to #2172.
上文提到的报错与 #2172 有关
Environments (please complete the following information) (required): / 请提供如下信息(必填)
The text was updated successfully, but these errors were encountered: