I'm working on an Expo React Native app that uses Redux Toolkit and RTK Query. We recently created some extra test accounts so that we could simulate user permissions, and we started running into issues where after logging out from Account 1
and logging in to Account 2
, requests still seemed to be made with Account 1
's tokens.
My initial assumption was that the Redux store was leaking state between user sessions, so I installed React Native Debugger. I verified that state management was working correctly, and enabled "Network Inspect" to take a look at the requests. Suddenly, everything began working as expected. I could switch between Account 1
and Account 2
repeatedly, and the RTK Query requests would return the correct data every time.
I've found some similar questions, but none of them have helped in this case:
- React Native Android: Fetch Requests only working when React Native Debugger is connected
- One of the answers mentions an "API issue", but all of our other requests work just fine
- Other answers are geared towards Android, but we're experiencing this on both Android and iOS (physical and simulators)
- urlencoded request works only if react native debugger's enable network inspect mode is switched on or in Postman
- We're already encoding our body params using a method similar to the one in the answer. Also, this user's requests were outright failing. Ours are not
I would really appreciate any help with this. It's driving me mad, and I spent hours trying to fix it today before I discovered this quirk with the debugger. Apologies for not including any code; given the nature of the problem, I'm really not sure which parts of the codebase (if any) would be useful. Thank you!