question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form.resetFields and onChange event

See original GitHub issue

What problem does this feature solve?

This feature would help alot while building dynamic forms (fields showing/hiding depends on previous picks). Currently its hard to fully reset form when form contains children components with own state edited by select onChange.

What does the proposed API look like?

'this.props.form.resetFields( {} , {triggerOnChange:true} )` or made onChange trigger as default.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
benjycuicommented, Jun 28, 2017

It’s weird.

You can trigger customized event:

form.resetFields();
trigger('clearSelect1');

on('clearSelect1', () => {
  // hide select2
});
1reaction
GravityMsccommented, May 17, 2018

@benjycui 我现在也碰到这种情况: 组件1 联动控制 组件2。 我在组件1加载完成后用setFields预填了内容,我期望setFields可以触发其onChange事件,进而影响到组件2,事实上并不如此。

或许我们可以在api上加上触发onChange的可选项?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Ant Design form.resetFields() doesn't call onChange ...
Since AntD Form is uncontrolled, there is no way to trigger onChange event by calling resetFields , setFieldsValues .
Read more >
Form - Ant Design
High performance Form component with data scope management. ... It has event onChange or an event which name is equal to the value...
Read more >
Solved: Combobox OnChange (Edit form) needs to reset field...
Solved: I have a combobox that has an OnChange value that auto-populates a text box and filters the item list for a second...
Read more >
useForm - resetField - Simple React forms validation
resetField : (name: string, options?: Record<string, boolean | any>) => void. Reset an individual field state. Props. After invoke this function.
Read more >
API Reference - Formik
<Formik> is a component that helps you with building forms. It uses a render props pattern made ... General input change event handler....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found