Created
July 3, 2018 19:59
-
-
Save adambray/cfb0cf15fce03c7500fab3f7967fcc38 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