You're building a simple task management feature for a productivity app. Users should be able to view tasks, mark them as complete, and add new tasks.
Design and plan the implementation for three React components using TypeScript:
- TaskList - Displays a list of tasks
- TaskItem - Represents a single task with a checkbox and text
- AddTaskForm - A form to add new tasks
- Tasks should have: id, title, and completed status
- Users can toggle a task's completion status by clicking a checkbox
- Users can add new tasks through a simple form with a text input and submit button
- The task list should update when tasks are added or their status changes
- How you think about component structure and data flow
- Your approach to TypeScript types/interfaces
- How you handle state management
- Component composition and props design
Take 20-30 minutes to:
- Explain your component architecture and data flow
- Define the TypeScript interfaces/types you'll need
- Write out the component signatures (props and basic structure)
- Walk through how the components interact
You don't need to implement every detail, but show your thinking process.
You can use https://codesandbox.io/p/sandbox/react-ts to implement your code
Here is some starter code
function App() {
const [tasks, setTasks] = useState<Task[]>([
{ id: "1", title: "Complete mock interview", completed: false },
{ id: "2", title: "Review React concepts", completed: true },
]);
return (
<div
style={{
maxWidth: "600px",
margin: "40px auto",
padding: "20px",
fontFamily: "Arial, sans-serif",
}}
>
<h1>Task Manager</h1>
</div>
);
}
export default App;-
If this task list grew to 1,000+ tasks, what performance concerns would you have? How would you address them?
- Look for: virtualization, pagination, memoization
-
How would you prevent unnecessary re-renders in the TaskItem components?
- Look for: React.memo, useCallback, useMemo
- Right now, where would you keep the task state? What if multiple components across different parts of the app needed access to tasks?
- Look for: context API, state management libraries, lifting state
-
How would you add the ability to edit a task's title? Walk me through the changes you'd make.
- Look for: controlled components, handling edit mode state
-
What happens if someone tries to add an empty task? How would you handle validation?
- Look for: form validation, error states, user feedback
-
If tasks needed to be saved to a backend API, how would your design change?
- Look for: async operations, loading states, error handling, optimistic updates
-
How would you test these components?
- Look for: unit testing approach, testing user interactions, mocking
-
Would you use types or interfaces for your task data? Why?
- Look for: understanding of differences, consistency reasoning
-
How would you handle optional properties if tasks could have additional fields like priority or dueDate?
- Look for: optional properties, union types, type guards