This project allows you to practice the concepts and techniques learned in this module and apply them in a concrete project. This module explored React components and component state. During the module, you studied what React is, what React components are and how to build them, what state is and how to make a component stateful, and how to update component state with click handlers. In this project you will demonstrate proficiency of these subjects and principles by fleshing out several stateful components.
Read these instructions carefully. Understand exactly what is expected before starting this project.
Commit your code regularly and meaningfully. This helps both you and your team lead in case you ever need to return to old code for any number of reasons.
This project includes a src/components
folder containing several React components. In their current form these components are stateless and display hard-coded information only. You will make the app interactive by going into each component, adding state and implementing event handlers and helper functions to allow the users of the app to update state by interacting with the page.
- Create a forked copy of this project.
- Clone your OWN fork of the repository using your terminal.
- CD into the project base directory.
- Download project dependencies by running
npm install
. - Start up the app using
npm start
. - Optionally run tests using
npm test
. (The app must be running onhttps://localhost:1234
) - Push commits:
git push origin main
.
- Each component has the required slices of state.
- Each component's event handlers allow the user of the app to update state.
- Updated state is correctly reflected in the DOM for each component.
- You will add functionality to all components inside inside
src/components
. - Work on the components in the same order in which they display in Chrome (to go from easiest challenge to hardest).
- Each file includes a link to a video, and a set of instructions which can be summarized as:
- Watch the video demoing the finished component, and think about how much state is needed.
- Create the necessary slices of component state using the state hook.
- Fix the JSX so it displays information derived from state, instead of hard-coded data.
- Fix the event handlers so they allow the user to update state by interacting with the page.
After finishing your required elements, you can push your work further. These goals may or may not be things you have learned in this module but they build on the material you just studied. Time allowing, stretch your limits and see if you can deliver on the following optional goals:
Create a Todos.js
file inside src/components
. Find a tutorial online on how to build a to-do list in React using component state (no Redux!), and implement it. We should be able to render a list of to-dos, and cross out (or remove) individual to-dos to mark them complete.
Build another component inside this project with a game of Tic Tac Toe. The positions of the 'Xs' and the 'Os' over time need to be maintained in a slice of state, so that the JSX may display the contents of the 3 x 3 grid accurately. Only empty squares may be selected by the human player, and the event handler that deals with these clicks will have to include quite a bit of logic:
- Does the latest move by the human player mean the game is over? (Game over, then!)
- Is the game immediately winnable by the computer by making a certain move? (Make that move!)
- Can the computer block the human from winning on their next move by making certain move? (Prevent defeat!)
The move by the computer should probably be random if the previous checks turn out negative, but you'll be surprised at how smart the "game engine" will feel.
- Submit a link to your repo in canvas.