Level 4 · Full-Stack Application Development · Course 4.1 React Fundamentals
Module 34: React Hooks
Goal: use useEffect to connect components to the world outside React, useRef to hold values and reach
elements, write your own hooks, and avoid the most common hook mistakes.
You'll need: your enquiries project from Module 33.
Lessons
- 1Effects with useEffect15–25 minutes✓
- 2Dependencies and cleanup15–25 minutes✓
- 3useRef15–25 minutes✓
- 4Custom hooks15–25 minutes✓
- 5The rules of hooks and common mistakes15–25 minutes✓
🛠️Module practice: a dashboard that remembers
- Enquiries saved and loaded with a
useLocalStoragehook. - A debounced search using a
useDebouncehook. - Keyboard shortcut
/to focus search, with proper listener cleanup. - "Last updated" time refreshing each minute with cleanup.
- A comment on every effect naming the outside system it connects to. No hook lint warnings. Commit.
✅Module check
Explain in a few sentences, in your own words:
What is useEffect for, when is it not needed, and what are the rules of hooks?
Show a good answer
A good answer mentions: useEffect runs code after rendering to sync with things outside React (localStorage,
timers, listeners, the page title, fetching), re-running when its dependencies change, and returning a cleanup
function to undo itself. It isn't needed for values that can be calculated during rendering. useRef holds values
or element references without re-rendering. Hooks must be called at the top level of components or custom hooks,
in the same order every render; custom hooks (named use…) share stateful logic.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
