Created
April 9, 2019 18:59
-
-
Save sibiraj-s/caadb2c8d4ed23175db1d2707217f4f3 to your computer and use it in GitHub Desktop.
React - Manually trigger onChange Event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use HTMLInputElement for text input | |
const nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set | |
nativeTextAreaValueSetter.call(inputRef, newTextareaValue) | |
const inputEvent = new Event('input', { bubbles: true }) | |
inputRef.dispatchEvent(inputEvent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment