Home  >  Q&A  >  body text

antd "clear" values ​​within cascade - Stack Overflow

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~!

天蓬老师天蓬老师2711 days ago787

reply all(4)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:38:29

    Clear the cascaded value in the componentDidMount life cycle

    reply
    0
  • 迷茫

    迷茫2017-05-19 10:38:29

    Bind the value of the component to the state and set an initial value.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-19 10:38:29

    I don’t know if the questioner used antd FormForm.item?如果是的话,antd 是使用了“高阶函数”的方式封装了 Form.Item,并将级联的 valueForm.IteminitialValuevalue(好吧,我也记不清了...) 关联了,二次封装的话,应该使用相应的 this.props.value 来控制封装逐渐内部的 value.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:38:29

    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.

    reply
    0
  • Cancelreply