State Management
79 bites tagged State Management — interview questions with model answers, and 60-second explainers.
Difference between remember and rememberSaveable
Remember survives recompositions only; rememberSaveable uses Bundle state for config changes and process death; use for UI state after recreation. Compose state vs saved state. Claiming it uses ViewModel or disk.
What is remember in Compose and how do you use mutableStateOf?
This tests state survival across recompositions. Good answers say remember caches values across recompositions, pairs with mutableStateOf for observable state, and shows a counter. A red flag is mutableStateOf without remember, state resets per recomposition.
Vue Provide/Inject: Skip Prop Drilling
Vue's provide/inject lets an ancestor component share data directly with any descendant, avoiding the tedious 'prop drilling' chain. Use it for app-wide data like user info or theme settings. The footgun: providing a simple value is not reactive by default.
Zustand: Lightweight Global State for React
Zustand provides simple global state management for React, feeling like a shared `useState` hook for your whole app. Use it in small to medium apps where Redux is overkill. The main footgun is its limited ecosystem, making it a risk for large-scale apps.
TanStack Query: Manage Server State, Not Client State
TanStack Query treats server data as a cache, not local state. It automates fetching, caching, and background updates to keep your React Native app in sync with your backend.
React Redux: Connecting Components to a Global Store
React Redux connects your React UI to a global Redux state store, letting components read data and dispatch updates. It's used to avoid "prop drilling" shared state across the app.
React Native's Controlled Switch Component
The Switch component is a 'controlled' input; it doesn't manage its own state. You use it for on/off settings by telling it what to display via the `value` prop and updating that state in the `onValueChange` callback. The footgun is forgetting this link.
Get State Management bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.