An app I have been building for the past month using react native suddenly stopped working and started showing a white screen upon running react-native run-ios
. Sometimes the emulator shows a yellowBox that says Possible Unhandled Promise Rejection
, but other than that, I cannot see any errors. The issue is happening in both the branch I was working on and the master branch, which was definitely stable at its last commit.
These are the dependencies I have currently:
"axios": "^0.17.1",
"base-64": "^0.1.0",
"firebase": "^4.8.1",
"query-string": "^5.0.1",
"react": "16.0.0",
"react-native": "0.51.0",
"react-native-dotenv": "^0.1.0",
"react-native-linear-gradient": "^2.4.0",
"react-navigation": "^1.0.0-beta.22",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-persist": "^5.4.0",
"redux-thunk": "^2.2.0"
Does anyone have any suggestions for how to overcome this obstacle? Or any tools that would help debug? I really would appreciate any help anyone could provide.
I believe I found the solution. The error was happening with the redux-persist
dependency.
In my Redux reducer, I had this case:
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case 'persist/REHYDRATE': {
if (action.payload.auth) {
const { access_token, refresh_token, expiration } = action.payload.auth;
return {
...state,
access_token: access_token,
refresh_token: refresh_token,
expiration: expiration,
};
} return state;
}
// other cases
}
But for some reason, there was no payload to the rehydration (hence the error Cannot read property "Auth" of undefined
).
I commented out this case, reloaded my simulator using cmd-R
, and everything seemed to work again! I'm not entirely sure why this fixed the problem, so if anyone has any thoughts, definitely feel free to share.