StaffCoder
React Native
React NativeReact Native 0.81
12 modules · 47 challengesSign up
Modules12 modules · 47 challenges
The device-persistence layer of a React Native app. Preferences, drafts and cached responses live in AsyncStorage under versioned or prefixed keys, and are always rehydrated on mount BEFORE the network is consulted so the UI shows the stored state instantly. Writes are debounced so rapid typing collapses to one setItem call per pause; a stored payload from an earlier version is migrated to the current shape rather than discarded; corrupt JSON falls back to defaults without throwing. Batch operations use multiSet, multiGet, multiRemove and getAllKeys with a prefix filter so aggregations across many stored records stay a single round trip. A cache-and-revalidate pattern serves cached data immediately and refetches behind the customer, respecting a TTL for skipping the request entirely and a hard staleness limit past which dependent actions are blocked.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

Travel Search Preferences

Sign up to unlock
—No data yetmedium
About this challenge

A traveller's search preferences screen in a flight booking app. Cabin class, baggage requirement, party composition and preferred airports are persisted to AsyncStorage under a versioned key. On mount the app hydrates and renders defaults until hydration completes, migrating a stored v1 payload into the v2 shape rather than discarding it. A reset clears the key and returns to defaults; corrupt JSON falls back to defaults without throwing. A matching-fares summary derives from the current preferences.

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

Exchange Rate Board Cache

Sign up to unlock
—No data yetmedium
About this challenge

The rate board in a currency app that serves cached rates instantly and revalidates behind the customer. The fetched rate set is cached in AsyncStorage alongside a timestamp; on mount the cache renders immediately when present, then revalidates. Requests are skipped entirely inside the TTL; a "rates as at <time>" label shows until revalidation completes; the convert action is blocked past a hard staleness limit. Force-refresh always requests and rewrites the cache; a failed revalidation keeps the cached rates and leaves the staleness label showing. Data comes from the platform's hosted read-only JSON API over fetch with the base URL injected through configuration.

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

Vehicle Inspection Records

Sign up to unlock
—No data yetmedium
About this challenge

A fleet inspector's screen for recording defect grades across a depot with no connection. One record per vehicle is stored under a prefixed AsyncStorage key. Batch writes and reads use multiSet and multiGet; getAllKeys with a prefix filter lists them and ignores unrelated keys. A depot summary aggregates defect grades across all stored records; clearing a vehicle's record uses multiRemove and updates the summary. A rejected batch leaves no half-written record behind.

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

Storefront Category Sorter

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

A merchandising screen where storefront categories are dragged into display order that survives a restart. Categories are reordered with PanResponder, animating position through the Animated API and springing into the settled slot on release. The resulting order is persisted to AsyncStorage after each drop and rehydrated on mount. A category released outside any slot springs back to its origin and persists nothing. A reset-order control returns to the default order. Star problem — accumulates the AsyncStorage persistence + migration discipline of 10300, the cache-and-revalidate rhythm of 10301, and the batch storage + summary aggregation of 10302, and lands them on a drag-driven ordering interaction whose result must survive a remount.

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.