Scenario description
1. Wrap the cascade component twice
2. Use it in the news list editing function. The editing function is to pop up a form box that mimics the box
Problem description
Every time you click on any of the pop-up pseudo-box forms for editing, select any value in the cascade component inside, then click to close the editing pseudo-box, and then click on any piece of news When editing, the pop-up simulation box will display the undetermined submitted value of the last selection by default.
Tried methods
Used the form reset methodresetFields
The value in the cascading box cannot be cleared. I found some posts in antd's github and the attempts are still invalid. I learned from one of the posts that https://github.com/ant-design...resetFields
is reset and cannot be cleared.
Ideal goal
Every time I click edit, I want to force clear the value inside.
Thank you everyone~!
Clear the cascaded value in the componentDidMount life cycle
Bind the value of the component to the state and set an initial value.
I don’t know if the questioner used antd
Form
和Form.item
?如果是的话,antd 是使用了“高阶函数”的方式封装了Form.Item
,并将级联的value
和Form.Item
的initialValue
或value
(好吧,我也记不清了...) 关联了,二次封装的话,应该使用相应的this.props.value
来控制封装逐渐内部的value
.I haven’t seen your code, so I don’t know how you implemented it, but the simplest way is to bind the value and state of your component. When you want to clear the value of the component, just reset the setState.