From the course: React in Action: From Setup to Deployment

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Using effects

Using effects

- [Instructor] The second most popular Hook in React is the useEffect Hook. This allows you to manage things that happen outside the scope of the current component, and it's often used with useState. I'm going to use it here pretty simply, and then, we'll expand on it in the next video. I'm going to add a variable here called pageTitle, and I'm going to use it to access the document.title, which will give me the title that is right here. Now I'm going to go ahead and modify that title, and I'll call it React in Action. That is what we want to target, and in our counter, we're storing that in this pageTitle variable. We're going to use the useEffect Hook to gain access to that component. So here, I'm going to say useEffect, and useEffect will let me have access to that document.title and modify it with our count. So I'm going to say count, and then I'm going to use a double ampersand here. I'm going to say document.title, and then, I'll put in these tick marks right here, which let me…

Contents