Last active
August 9, 2021 11:07
-
-
Save EminQasimov/f691b60c035a3d0cc6b3d1fe6c122986 to your computer and use it in GitHub Desktop.
performance trick for intensive ui updates - react rerenders, inputs
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
let queued = false | |
textarea.addEventListener('input', () => { | |
if (!queued) { | |
queued = true | |
requestIdleCallback(() => { | |
updateUI(textarea.value) | |
queued = false | |
}) | |
} | |
}) | |
// link: https://nolanlawson.com/2021/08/08/improving-responsiveness-in-text-inputs/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment