Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 27.5 — Accessibility, Performance and Tests
React · Example 2 of 3

Measure first: render counts with and without memo

Each keystroke re-renders every matching plain card although no task changed; the memo cards render 0 times, because each task prop is the same object as before. Only measured waste like this earns a memo.

Milestone 5: make every action work from the keyboard, keep focus on a card when it moves, announce changes to screen readers, add memo only where render counts show wasted work, and prove the behaviour with Testing Library tests.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Make Escape in a card's edit box return focus to that card's ✎ button.

02

Write a test that the Add button doesn't add an empty task.

Explain it without notes

01

Why does focus get lost when a card moves to another column, and how do you fix it?

02

What is a live region and how should you render one in React?

03

When would you add memo to TaskCard, and what makes it work?

04

How do role-based queries in tests double as accessibility checks?

Measure first: render counts with and without memo

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

first render: { plain: 4, memo: 4 }
typed "t": { plain: 3, memo: 0 }
typed "te": { plain: 1, memo: 0 }
typed "tes": { plain: 1, memo: 0 }