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

Introduction to Hooks

Developed with
QA
play-arrow
Start course
Overview
DifficultyIntermediate
Duration31m
Students21

Description

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.  

Prerequisites

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. 

Feedback 

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

Transcript

Facebook have moved to promote the use of Functional Components and to do this React needed a mechanism to add State to them and also to support other features. One of the main objectives was to make any new way of creating components backwards compatible. React version 16.8 is the one with Hooks, but what are Hooks, Hooks let you literally hook into React's state and lifecycle features. In terms of Functional Components, this solved a raft of problems encountered by the React team. These being the reuse of stateful logic between components, the splitting of complex components into smaller functions based on their relationships and the simplification of code syntax. Class components being simplified to functional components is much like syntax and code required. It makes the building optimization process better as there's less to transpile. To re-iterate, there is no need to rewrite class components in applications as functions, as class components will always be valid. It's just recommended that new components should be built as functions using Hooks. State Hooks are available in React and what do they do, there are a few Hooks built into the library already. If you've covered the content on 'Thinking in React', we use a State Hook to allow functional components to have state. Another hook that is commonly used out of the box, is the Effect Hook. The Effect Hook is the one that allows us to hook into the lifecycle methods that we would see in a class component to perform side effects, hence its name. We'll go into more detail about this hook later. React has some other Hooks and we'll look into the useContext and useReducer Hooks when we investigate other state management techniques. There's also useMemo, useCallback, useRef, useImperativeHandle, useLayoutEffect and useDebugValue. The last one, useDebugValue is perhaps the most interesting for developers as it lets us display a label for Custom Hooks in the DevTools and talking of Custom Hooks, we aren't limited to those Hooks provided by React. We can create Custom Hooks to do almost anything we need them to, as long as we follow the rules for Hooks, and the steps for creating our own hook, as outlined in React's official documentation.

About the Author

Students1293
Labs8
Courses29
Learning paths5

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