Once we have a ref set up, we gain the ability to access that ref within React's useEffect hook.
With this, we'll access the current value at the time the useEffect hook is ran.
You can test this out by using the console.log feature and verifying that when logging inside of useEffect, you'll see that your ref has a property of current with a value.
Instructor: [0:00] In order to access our map from our ref we're going to use the useEffect Hook. We can start by creating a new instance of this hook where we pass in an empty function.
[0:06] For the dependency array, we're going to set our mapRef. In order to test this out, we can console.log() out our mapRef, and we can actually specify the current property. If we reload the page, we can see that we now our console logging out our map.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!