StaffCoder
React Native
React NativeReact Native 0.81
12 modules · 47 challengesSign up
Modules12 modules · 47 challenges
The shared-state layer of a React Native app. State lives in a useReducer, exposed through split contexts — a value context for the state itself and a dispatch context for the raw dispatch function, whose identity is stable across renders so callbacks passed into memoised children never change. When one part of the state changes at a different cadence to another — a ticking clock, a search query, a shortlist — it lives in its own third context so subscribers to unrelated slices don't re-render. Derived values (totals, filtered lists, grouped sections, counts) are computed by selectors on every render, never mirrored into a second useState. Row components subscribe to only the slice they render — often through a bins-by-id map so one bin's change gives that entry a new reference while every other entry stays === identical.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

Travel Booking Basket

Sign up to unlock
—No data yetmedium
About this challenge

The basket a traveller taps through while assembling a trip from flights, rooms and extras. A basket context backed by a reducer handles add item, change quantity, apply option (fare class, board type) and remove line; taxes, fees and totals are computed by selectors rather than stored. Removing a line requires a reason recorded against it — an empty reason returns the previous state unchanged. The product grid does not re-render when only the basket changes

Solved in a browser IDE and graded by tests. Sign up to solve

Store Rota Board

Sign up to unlock
—No data yetmedium
About this challenge

The rota board in a retail store manager's app where a ticking clock does not re-render the whole board. App state is split into separate value and dispatch contexts; the trading-hour clock lives in a third context of its own so shift rows subscribe only to what they use. Memoised consumers ensure a clock tick re-renders the clock strip alone; dispatching a shift assignment re-renders the affected row and nothing else. An interval ticks the clock every second and is torn down on unmount.

Solved in a browser IDE and graded by tests. Sign up to solve

Property Search Board

Sign up to unlock
—No data yetmedium
About this challenge

The search board in a property app where typing in the search bar does not re-render every listing on screen. App state is split into value and dispatch contexts, and the search query lives in a third context of its own so listing rows subscribe only to the listing they render. Callback identities taken from the dispatch context stay stable across parent re-renders, so a keystroke re-renders the query bar and the result-count header alone. Data comes from the platform's hosted read-only JSON API over fetch, with the base URL injected through configuration so tests can point at a seeded instance.

Solved in a browser IDE and graded by tests. Sign up to solve

Warehouse Bin Stock Console

STAR
Solving it completes the module
—No data yetmedium
About this challenge

The stock console where a large bin grid reads shared state without the whole grid re-rendering on every adjustment. Bin state lives in a context backed by a reducer with bins keyed by id; the grid renders every bin through a memoised row subscribing to its own bin only, with stable callback identities taken from the dispatch context. Adjusting one bin's on-hand quantity updates the totals bar without touching unrelated rows; a bulk cycle-count action gives each affected bin one new reference and leaves the rest unchanged. Star problem — accumulates the reducer + derived totals discipline of 10322, the split value / dispatch contexts of 10323, and the stable-callback / row-scoped subscription discipline of 10324, and lands them on a bins-by-id map that lets one change ripple through exactly one row.

Solved in a browser IDE and graded by tests. Sign up to solve

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.