Week 6

useEffect - Side Effects, Data Fetching & Async State

Browser DevTools - The Network Tab

Tailwind v4

React Router

Deployment with Vercel

Practice

Assignment

Front end Track

Content

Let’s get practical

Exercise 1: Fetch and Display Data with useEffect

Difficulty: Easy Concepts: useEffect, data fetching, async state (loading, error, success)

Build a component that fetches and displays a list of items from a public REST API of your choice.

Requirements:

Hints:

Exercise 2: Search with Dynamic Fetching and Cleanup

Difficulty: Medium Concepts: useEffect dependencies, cleanup, AbortController, controlled inputs

Extend what you built in Exercise 1 into a searchable interface where the fetch re-runs based on user input.

Requirements:

Hints:

Exercise 3: Network Tab Investigation

Difficulty: Easy Concepts: Browser DevTools, Network tab, watching fetch calls, HTTP status codes

Use the browser's Network tab to observe and understand what your Exercise 2 component is actually doing over the network.

Requirements:

Open your Exercise 2 component in the browser with DevTools open on the Network tab, filtered to Fetch/XHR. Complete each of the following tasks and write down your answers in a comment block at the top of your component file:

  1. Find a successful request — type a search query and let it complete. Click the request row and open the Headers tab. What is the full request URL? What status code did the server return?
  2. Inspect the response — with the same request selected, open the Preview tab. Does the shape of the data match what you expected? Note one field from the response that your component is currently not displaying.
  3. Catch a cancelled request — type several characters quickly without pausing. Do you see any requests with a (cancelled) status? This is your AbortController cleanup working. If you don't see any cancellations, try typing faster.
  4. Trigger a 404 — temporarily change your fetch URL to something that doesn't exist (add a typo, like /userss instead of /users). What status code appears in the Network tab? What does the Preview tab show: is it JSON or something else?
  5. Simulate a slow connection — set the throttling dropdown to Slow 3G and trigger a fresh fetch. How long does the request take according to the Time column? Is your loading state visible long enough to notice?

Set throttling back to No throttling when you're done.

Hints:

Exercise 4: Native CSS to Tailwind

Difficulty: Easy Concepts: Tailwind utility classes, how Tailwind maps to CSS properties

Convert the CSS below to Tailwind utility classes applied directly to the JSX. The goal is to produce a visually identical result without writing any CSS.

Starting point — the CSS:

.card {
  background-color: #ffffff;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  max-width: 28rem;
  width: 100%;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.5rem;
}

.card-body {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.625;
  margin-bottom: 1.5rem;
}

.card-button {
  display: inline-block;
  background-color: #2563eb;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
}

.card-button:hover {
  background-color: #1d4ed8;
}

@media (min-width: 640px) {
  .card {
    padding: 2rem;
  }
}

Starting point — the JSX (with CSS classes):

export default function Card() {
  return (
    <div className="card">
      <h2 className="card-title">Getting started</h2>
      <p className="card-body">
        This is a simple card component. It has a title, some body text, and a call-to-action button below.
      </p>
      <button className="card-button">Learn more</button>
    </div>
  );
}

Requirements:

Hints:


The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

CC BY-NC-SA 4.0 Icons

Built with ❤️ by the HackYourFuture community · Thank you, contributors

Found a mistake or have a suggestion? Let us know in the feedback form.