Access and Modify a DOM Node with the React useRef and useEffect Hooks

Kent C. Dodds
InstructorKent C. Dodds
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 3 years ago

To use VanillaTilt we need to get access to a div so that it can work its magic. To make this happen we'll learn about React's useRef and useEffect methods.

We'll cover:

  • Creating a reference to a DOM node with useRef
  • Making a callback function using useEffect
  • Using .init to assign VanillaTilt to that DOM node
  • Returning a cleanup function to avoid memory leaks
  • Initializing useEffect with a dependency list to prevent rerendering.
Isabella HU
Isabella HU
~ 5 years ago

hi, there is a problem with this video. it stuck at 00:11

Markdown supported.
Become a member to join the discussionEnroll Today