This module explored lifecycle methods in class components. In your project you will demonstrate proficiency of these concepts by building a todo app that can interact with an API to read, create and edit todos.
- Building class components from scratch
- Using
ComponentDidMountto trigger a request to the server after the first render - Using a submit event handler to create (
POST) a new resource to the server - Using a click handler to edit (
PATCH) an existing resource on the server - Updating the frontend to keep it in sync with the state of the server
- Filtering out of view the completed todos
In this project you will build an application that allows for todos to be added, completed and removed from view. This application should:
- Use this gif as inspiration for building the DOM
- Try out this prototype
- Hold all todos in state within the
App.jscomponent - Allow for a todo's
completedstatus to be toggled back and forth when clicking on a todo - Allow for a todo to be added when submitting the new todo form
- Allow for completed todos to be filtered out of view when clicking the clear completed button
- Node 16.x
- NPM 8.x (update NPM executing
npm i -g npm) - Postman (download the desktop version here)
- Chrome >= 96.x
Other browser/Node/NPM configurations might work but haven't been tested.
- Fork, clone, and
npm install. - Launch the project on a development server executing
npm run dev. - Visit your app by navigating to
http://localhost:3000with Chrome.
The following endpoints exist in this project and should be explored with Postman prior to coding:
GET http://localhost:9000/api/todos- Expects no payload
- Makes no changes on the server
- responds with
200 OKand a payload with all the todos
POST http://localhost:9000/api/todos- Expects a payload with
name(string) and optionalcompleted(boolean) - Creates a new todo on the server
- responds with
201 Createdand a payload with the new todo
- Expects a payload with
PATCH http://localhost:9000/api/todos/:id- Expects no payload
- Flips the
completedproperty on the todo with the id provided in the URL - Responds with
200 OKand the updated todo
The API will make other responses if the requests are defective:
422 Unprocessable Entitywhen a required payload is missing or incorrect404 Not Foundwhen the requested todo does not exist, or when the URL is incorrect
Build all components as class components. Find them inside frontend/components. Don't focus on styling. We want you to worry about function over form today. Your React application must consume the endpoints above to achieve the following functionality:
- Your app should display a list of todos, an input field, a submit button, and a button to filter out completed todos
<App />will hold all of the state machinery:- Application state, held in component state
- State-changing methods, event handlers
<TodoList />receives your todos array and iterates over the list generating a new<Todo />for each element in the array<Todo />is a component that takes in thetododata and displays the task to the screen<Form />will hold your input field and yourAdd TodoandClear Completedbuttons- Your input field should take in user input, and allow a user to press
Enteror click on theSubmit Buttonto add a todo to your list - Once a todo is submitted, the Todo List should re-render and show the added todo
- Your input field should take in user input, and allow a user to press
- Only work on main.
- Avoid committing broken code, but commit as often as possible
- Refer to Canvas for additional submission instructions