Todo App
This is a tried-and-true interview challenge!
Below, you'll find static markup for a Todo list application. Your job is to make it reactive, so that the state is tracked in React, and new items can be added to the list.
Difficulty
I'd say this is a medium-difficulty challenge, the sort of thing you might be expected to do in a junior developer interview. It's similar to things we've done in the course, so hopefully that makes this a bit easier!
Rules
- Immer has been installed in this playground, if you wish to use it. Otherwise, no third-party libraries are allowed.
- Feel free to google anything you'd like.
Playground
Code Playground
/*
Acceptance Criteria:
• It should be possible to add new todos by typing in the main input and pressing "Enter".
• Todos can be marked as completed by clicking them. Clicking again will mark it as incomplete.
• There should be no key warnings, and your approach should be fully accessible.
*/
import React from 'react';
function App() {
return (
<main>
<form>
<label htmlFor="todo-input">
What needs to be done?
</label>
<input id="todo-input" />
</form>
<ol>
<li>
<input type="checkbox" id="todo-1" />
<label htmlFor="todo-1">Invite classmates</label>
</li>
<li>
<input type="checkbox" id="todo-2" />
<label htmlFor="todo-2">Hire clown</label>
</li>
<li>
<input type="checkbox" id="todo-3" />
<label htmlFor="todo-3">Order bouncy castle</label>
</li>
</ol>
</main>
);
}
export default App;