Create a small React application that displays and updates a list. You will build at least two custom components that use props to influence their appearance.
npm create vite@latest
cd 09-react-basics
npm install
npm run dev
Open src/App.jsx and remove all the default JSX. Start with:
import { useState } from "react";
function App() {
return (
<div>
{/* Build your UI here */}
</div>
);
}
export default App;
Inside App, create state that holds an array of items:
const [items, setItems] = useState([
{ text: "Example Item", important: true }
]);
Customize what your list of items are. For example:
Use map() to loop through the list and display each item:
{items.map((item, index) => (
<ListItem
key={index}
text={item.text}
important={item.important}
/>
))}
You need to implement this ListItem component.
Create an input and button so the user can add items:
const [inputValue, setInputValue] = useState("");
function handleAdd() {
setItems([...items, { text: inputValue, important: false }]);
setInputValue("");
}
You will need to add the input and button in the same place you put the items.map.
Component #1 — ListItem.jsx
Have the ListItem look different in some way based on the item itself.Component #2 — Up to you
Create another component that is reused at least twice. It could be a part of the ListItem.Edit App.css or create new styles. Make it look your own.
In this part, you will add routing to your application and fetch data from an external API using useEffect.
First, install the routing library:
npm install react-router-dom
Modify your App.jsx to use React Router. You'll need at least three routes:
/) that displays your list from Part 1Note: you'll need to move the list of items from Part 1 into a new component.
See this routing example from class for an example of routing setup.
Create a new component that:
useEffect to fetch data from an external API when the component mounts or when a dependency changesuseState to store the fetched dataImportant: You cannot use the Pokemon API (pokeapi.co) that was used in the class example. Choose a different public API. Some suggestions:
See RandomPokemon.jsx for an example of using useEffect with an API (remember to use a different API!).
npm run build
This creates a folder named dist.
index.html file inside of the dist directory by adding a ./ to the src property links on the script and link elements (e.g. src="./assets/index-DhduZZiG.js")dist folder from your React project.csc336-fall2025 root directory.09-react-basics-live
It should be visible by going to:
https://<your-github-username>.github.io/csc336-fall2025/09-react-basics-live