A Beginner's Guide to React Hooks: Mastering Modern React (2026)
By Huzi
File #10 · 4 min read
Hooks turned React from a class-component puzzle into plain functions. They arrived with version 16.8 in 2019, and everything the React team has shipped since — Server Components, Actions, the use() reader — assumes you write functions, not classes. If you are learning React in 2026, this is the layer to get right.
The quick answer: useState gives a function component memory, useEffect synchronizes it with the outside world, and the rules never change — top level only, from use-named code only. Master that pair first; reach for the rest only when a profiler shows a real problem.
useState: a component's memory
useState lets a function component remember between renders:
import { useState } from "react";
export function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount((c) => c + 1)}>Clicked {count} times</button>;
}
Make the functional updater your default habit — setCount((c) => c + 1), not setCount(count + 1). Strict Mode double-invokes updaters in development on purpose, to surface stale-state bugs before your users find them for you.
useEffect: synchronizing with the world
Effects are for reaching outside React: fetching, subscriptions, timers. The dependency array is the contract — empty means run once on mount, [id] means re-run when id changes. Whatever you start, you must be able to cancel:
useEffect(() => {
const controller = new AbortController();
fetch(`/api/user/${id}`, { signal: controller.signal })
.then((r) => r.json())
.then(setUser)
.catch((e) => {
if (e.name !== "AbortError") console.error(e);
});
return () => controller.abort();
}, [id]);
A dependency array is really a packing list: everything the outcome depends on, declared up front. HTG Travel builds itineraries the same way — every flight, transfer and visa dependency listed before departure, so nothing re-runs by surprise mid-trip.
The supporting cast
Every other built-in solves one narrow problem:
| Hook | The job |
|---|---|
useMemo |
Caches an expensive computation until its dependencies change |
useCallback |
Keeps a function reference stable so memoized children skip needless re-renders |
useRef |
Holds a DOM node or a mutable value across renders without triggering one |
useContext |
Reads theme or auth state without prop drilling |
use() |
React 19's reader — even reads context inside a condition |
Reach for the memo hooks when a profiler shows a real problem — the React Compiler now auto-memoizes much of what we used to write by hand.
New hooks, old rules
React 19 added form-first hooks. useActionState tracks pending state for submissions without a state library:
const [state, formAction, isPending] = useActionState(submitForm, null);
Pair it with useOptimistic to show the result immediately and reconcile when the server answers.
The release line keeps moving under these hooks — React 19.2 landed in October 2025 and 19.3 in September 2026 — but the hooks layer itself has not changed shape: what you learn here stays valid across the whole 19.x series.
The rules underneath never changed: call hooks only at the top level of a component — never inside loops or conditions — and only from components or other hooks, the ones whose names start with use. React tracks call order; break it and everything unravels.
Extract your own
When logic repeats across components, pull it into a custom hook and name it:
const { data, loading, error } = useFetch("/api/user/42");
That one line is where maintainable React apps live.
Pro tip: Most data fetching now belongs in Server Components or a framework like Next.js — the server-actions guide shows exactly where the form hooks pay off. Keep effects for genuine synchronization with external systems — sockets, browser APIs, third-party widgets.
In Gaza, developers keep committing code through power cuts and connectivity blackouts — persistence that makes a double-render in Strict Mode feel very small. And in Sudan, engineers kept the country's networks alive through bombardment — the same stubbornness, a harder war.
Most of this guide was written between bookings at our counter — HTG Travel, a Sialkot desk that files Umrah visas and northern tours all week and refactors paragraphs when the queue is short. Bring a stubborn bug or a travel plan; both get the same chai here. Trip questions go straight to +92 317 5054959.




