Created
October 19, 2022 07:33
-
-
Save simenbrekken-visma/f0e59853f82021945a5c947b5e2fa407 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
/** | |
* React overwrites the native value setter for HTMLInputElement so have to go deeper. | |
* | |
* @see https://github.com/facebook/react/issues/11600#issuecomment-345813130 | |
*/ | |
function setNativeInputValue(input: HTMLInputElement, value: string) { | |
Object.getOwnPropertyDescriptor( | |
HTMLInputElement.prototype, | |
'value' | |
)?.set?.call(input, value); | |
input.dispatchEvent(new Event('input', { bubbles: true })); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment