Manually handle the `onChange`?
See original GitHub issueBug, Feature, or Question?
Question/Feature?
Current Behavior
I have a custom dropdown component that returns on onChange
just the array of selected options. I can’t find a way to make it play nicely with Formik.
Desired Behavior
I’d like to be able to manually handle the onChange
call so that I can manually define which field is being modified and with what data.
Suggested Solutions
Something like:
handleChangeManually({
name: 'something',
value: [1, 2, 3]
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How can I trigger an onchange event manually? [duplicate]
Hence I'm looking for a way to manually trigger this onchange event (which I guess should take care of checking the value difference...
Read more >How can I trigger an onchange event manually in javascript?
Triggering the event manually − const e = new Event("change"); const element = document.querySelector('#test') element.dispatchEvent(e);.
Read more >How to Handle Multiple Inputs with a Single onChange ...
Besides handling just one input, a single onChange handler can be set up to handle many different inputs in the form.
Read more >SCR19: Using an onchange event on a select element ... - W3C
The objective of this technique is to demonstrate how to correctly use an onchange event with a select element to update other elements...
Read more >Solved: How to call a text input's onChange action manuall...
This works fine by itself. However i am to call the onChange action on this text input so that a set of instructions...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can use
setFieldValue('something', [1,2,3])
and wrap your input in a custom component.On my custom component I did:
in order to trigger the change and also the validation, and the ErrorMessage shows up correctly
The
onChange
prop of the Form (Formik) though, does not seem to trigger