Frontend Developer · Focus area 1: Advanced frameworks
FE2: Managing shared state
Goal: decide where each piece of information in an app should live and how screens share it: the kinds of state, React context, store libraries such as Zustand and Redux Toolkit, server data with a caching library, and the URL as state.
You'll need: your Kirana Express project from FE1, the state management ideas from Module 37, and a small fake API (a JSON file or a mock server) for products, cart and orders.
Where this is used: any app with more than one screen: a cart shown in the header and on the checkout page, a logged-in user shown everywhere, filters that should survive a page refresh. Getting state in the wrong place causes stale data, extra requests and bugs that only appear on some screens.
How it differs: a backend developer keeps one source of truth in a database. A frontend developer juggles several copies at once (what the server says, what the screen shows, what the user is typing) and must keep them in step without slowing the app.
Time: reading about 2 hours · practice (the Try it tasks) about 3 hours · assignment about 3 to 4 hours.
Lessons
- 1Kinds of state and where each livesReading 15–25 minutes, plus practice✓
- 2Context, and its costsReading 15–25 minutes, plus practice✓
- 3Stores: Zustand and Redux ToolkitReading 15–25 minutes, plus practice✓
- 4Server data with a caching libraryReading 15–25 minutes, plus practice✓
- 5The URL as stateReading 15–25 minutes, plus practice✓
🛠️Assignment: Shared state for the Kirana Express app
This sets up the state design for the multi-page app project.
- Write a state map of at least ten values with kind, home, refresh and sharing needs.
- Split any broad context into narrow ones, and measure renders before and after.
- Move the cart into a store with actions, selectors and safe persistence.
- Move server data into a caching library with chosen staleTimes, and add an order mutation with invalidation.
- Move search, filters, sort and page into the URL, validating values read from it.
Self-check before you finish:
- [ ] No value is stored twice where it could be calculated.
- [ ] Adding to the cart re-renders only the components that show the cart.
- [ ] Placing an order updates both the order list and stock without a refresh.
- [ ] Back, refresh and a shared link all restore the same search.
- [ ] No personal data appears in URLs or persisted storage unless needed.
✅Module check
Explain in a few sentences, in your own words:
How do you decide where each piece of state lives in a frontend app?
Show a good answer
A good answer mentions: the kinds of state (local UI, shared UI, server, URL, form) and asking who owns and needs each value; calculating derived values instead of storing copies; context for rarely changing shared values, split by how often they change; a store with actions and selectors for frequently changing shared state, updated without changing in place; a caching library for server data with staleTime, invalidation and optimistic updates; and the URL for refreshable, shareable state, without personal data.
📚Official references
Official documentation and guidance for this module's topics, chosen on 2 November 2026. Tools, laws and standards change, so check the current version before you rely on a detail. If a link has moved, search the same site.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
