By: Burton Podczerwinski
1 minute read
That's great, but what are we supposed to do with a modern framework like React? Directly accessing and manipulating the DOM is considered an anti-pattern in React, so ughh... what now?
Enter stage left: the useRef() hook. Let's take a look.
Ref's can be used to access DOM nodes and ReactNodes that have already been rendered. Here are the steps...
Create a constant to track your
ref-attribute to element that you want to track.