1. Home
  2. Training Library
  3. Programming
  4. Courses
  5. React - Working with External Data

How to use Effect Hooks

Developed with

The course is part of this learning path

ReactJS: Zero to Hero
Start course


This module looks at how to work with External Data in React. You’ll be looking at Class Components, Effect Hooks, and how to handle data.  

Learning Objectives 

The objectives of this module are to provide you with an understanding of: 

  • The component lifecycle  
  • Hooks in React  
  • How to create restful services  
  • How to use an Effect Dependency Array  
  • How to hand errors in data requests 
  • How to send data   

Intended Audience

This learning path is aimed at all who wish to learn how to use the ReactJS framework.  


It is essential you understand the face of contemporary web development to attend this course. We insist upon JavaScript experience, along with good HTML and CSS skills. 


We welcome all feedback and suggestions - please contact us at qa.elearningadmin@qa.com to let us know what you think. 


The use effect hook is there for state. But what about lifecycle methods? How do we hook into the life cycle methods like ComponentDidMount, ComponentDidUpdate and ComponentWillUnmount? These lifecycle methods often perform side effects that updates stating components and make requests for data. Step up the effect hook, use effect. This effectively replaces all three of those lifecycle methods in one callback function. The use effect hook runs after React flushes changes to the DOM after every render including after the initial one. It takes an argument of a callback function to execute when use effect is run and optionally an array of dependencies for the effect. We'll come back to this array later. We declare use effect inside the component's function body so it and its callback, both have access to the components props and state. Use effect callback can update state by calling the state of data functions. The main body of the callback function replaces ComponentDidMount and ComponentDidUpdate lifecycle methods found in class components. Cleanup is also performed by the use effect hook by adding a return to its callback. The return itself should be a callback that performs the required tasks. We can have more than one effect hook in a component.

About the Author
Learning paths6

An outstanding trainer in software development with more than 15 years experience as a Corporate and Apprentice Trainer, ICT Teacher and Head of Department, with a passion for technology and its uses. Continuing to develop existing and new skills and courses, primarily in web design using PHP, JavaScript, HTML, CSS and SQL but also OOP (Java), programming foundations (Using Python), DevOps (Git, CI/CD, etc) and Agile/Scrum. Practically minded, a quick learner and a problem solver with an attention to detail to ensure high quality outcomes.

Covered Topics