Command Palette

Search for a command to run...

Hectal
Phase 27: Capstone: Build a Complete App
React · Exercise 3 of 6 PreviousNext
Advanced

Milestone 3: save the board to localStorage

The tasks now live in an external store read with useSyncExternalStore, but nothing is saved. Finish taskStore.js.

Save the tasks as JSON under the key hectal-board after every dispatch. readSaved() must return the saved array, or SEED_TASKS when the key is missing, the JSON is broken, or the value isn't an array.

The Reload from storage button (#reload) calls store.reload(), which re-reads storage: it stands in for reloading the page. (The preview's localStorage is in memory and resets on every Run.)

What Check tests

  1. Adding a task saves it under hectal-board
  2. Reload shows what is in storage
  3. Broken JSON falls back to the seed tasks
  4. A value that isn't an array falls back too
  5. Moving a card after reload is saved again

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.