Week 4 - React Fundamentals

Why React?

Setting up a React project with Vite

Components

JSX

Props

Rendering lists

Conditional rendering

The mental model: how React renders (2)

Practice

Assignment

Front end Track

Let's get practical

Exercise 1: Build Your First Component

Difficulty: Easy Concepts: Functional components, JSX, embedding JavaScript expressions

Build a ProfileCard component that renders a small profile box for one person, using only hardcoded data inside the component itself.

Requirements:

Hints:

Exercise 2: Fix the Broken JSX

Difficulty: Easy Concepts: HTML vs JSX, attribute differences, inline styles

Take the broken component below, paste it into a fresh project, and fix every error so it renders without warnings in the browser console.

Starting point — the broken JSX:

JSX

const BrokenCard = () => {
	return (
		<div class="card" style="padding: 10px; background: #f0f0f0;">
			<h2>Welcome!</h2>
			<p>This card is broken.</p>
			<img src="logo.png">
			<label for="name">Your name:</label>
			<input type="text" id="name">
			<button onclick="alert('hi')">Click me</button>
			<!-- TODO: add more content -->
		</div>
	);
};

export default BrokenCard;

Requirements:

Hints:

Exercise 3: Refactor Static Markup into Components with Props

Difficulty: Medium Concepts: Component decomposition, props, destructuring, prop defaults

Take a single large App component and break it into smaller reusable components that receive their data through props.

Starting point — paste this into App.jsx:

JSX

const App = () => {
	return (
		<div>
			<header>
				<h1>My Travel Blog</h1>
				<nav>
					<a href="/">Home</a>
					<a href="/posts">Posts</a>
					<a href="/about">About</a>
				</nav>
			</header>

			<main>
				<article>
					<h2>3 days in Lisbon</h2>
					<p>Posted on 12 March 2026</p>
					<p>Lisbon was sunny and full of pastel de nata...</p>
				</article>

				<article>
					<h2>A weekend in Berlin</h2>
					<p>Posted on 5 February 2026</p>
					<p>Berlin in winter is cold but full of life...</p>
				</article>
			</main>

			<footer>
				<p>© 2026 My Travel Blog</p>
			</footer>
		</div>
	);
};

export default App;

Requirements:

Hints:

Exercise 4: Render a Filterable List

Difficulty: Medium Concepts: Rendering lists with .map(), unique keys, conditional rendering, empty states

Build a small product catalogue that renders a list of items from an array, with conditional badges and a graceful empty state.

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.