prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

Empty profile object even after redux persist rehydrates data #1119

Closed maderesponsively closed 2 years ago

maderesponsively commented 2 years ago

Bug: Profile object being set as {isEmpty: true, isLoaded: false} in between redux persist rehydrating data and react redux firebase fetching profile data.

See screenshot

image

Packages installed: "@react-native-async-storage/async-storage": "^1.15.5", "@react-native-firebase/app": "^12.2.0", "@react-native-firebase/auth": "^12.1.0", "@react-native-firebase/firestore": "^12.2.0", "@reduxjs/toolkit": "^1.6.0", "react": "17.0.1", "react-native": "0.64.2", "react-redux": "^7.2.4", "react-redux-firebase": "^3.10.0", "redux": "^4.1.0", "redux-firestore": "^0.15.0", "redux-persist": "^6.0.0",

I can see the profile reducer on 'LOGIN' is determining this:

case LOGIN:
// Support keeping data when logging out
if (action.preserve && action.preserve.profile) {
  return preserveValuesFromState(state, action.preserve.profile, {
    isLoaded: true,
    isEmpty: true
  })
}
return {
  isEmpty: true,
  isLoaded: false
}

Line: 301 https://github.com/prescottprue/react-redux-firebase/blob/4c780375d82ad7ebee436b7d7ebc5a15e3b794fc/src/reducers.js