Interview frequency: …
Short answer
Revoke all tokens from secure storage (SecureStore/Keychain), clear cached data in MMKV and QueryClient, and reset global state stores (Zustand/Redux) to their initial state.
Explanation
Failing to clear data on logout is a serious security risk: the next user on the same device could see the previous user's cached messages or data. Create a centralized cleanup function that runs storage.clearAll(), SecureStore.deleteItemAsync(), and queryClient.clear() together.
Code example
async function handleUserLogout() {
// 1. Clear encrypted authentication tokens
await SecureStore.deleteItemAsync('auth_token');
// 2. Clear the cache for API
queryClient.clear();
// 3. Reset state stores
useUserStore.getState().reset();
// 4. Delete fast local storage
storage.clearAll();
}Common mistakes
- Only clearing the token from in-memory state without deleting it from persistent storage or clearing query caches.
Follow-up questions
- How do you manage local and remote push notifications and their tokens?
- How do you use Zustand with MMKV to create a synchronous global state store persisted locally?