Created
February 27, 2019 21:07
-
-
Save adambray/1c81ab86c4d58de07b6cdabe2c09cf13 to your computer and use it in GitHub Desktop.
This file contains 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
function setInputValue(id, value) { | |
const input = document.getElementById(id); | |
const lastValue = input.value; | |
input.value = value; | |
// react 16 hack | |
let tracker = input._valueTracker; | |
if (tracker) { | |
tracker.setValue(lastValue); | |
} | |
input.dispatchEvent(new Event('input', {'bubbles': true, 'cancelable': true})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment