How to capture a value change made on the DOM in React

Alexandria Lalli
4 min readFeb 16, 2023

--

So you, like myself, have a weird scenario where you need to mutate the DOM directly in React. Why else would you have found this oddly specific blog post? It’s okay, I’ve got you. You’re in good hands now.

I won’t dive too deep into why this was required, but the top-level is… we are using a Google Tag Manager to set hidden fields in a controlled form.

--

--

Alexandria Lalli

Full-Stack Engineer, UX/UI Aficionado, and lover of coffee.