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

React Native Unhandled Promise Using Database instead of Firestore #1174

Open brhoomjs opened 2 years ago

brhoomjs commented 2 years ago

Do you want to request a feature or report a bug?
bug

(If this is a usage question, please do not post it here—post it on gitter. If this is not a “feature” or a “bug”, or the phrase “How do I...?” applies, then it's probably a usage question.)

What is the current behavior? After sign in with RNFirebase I got this error:

Possible Unhandled Promise Rejection (id: 0):
Error: You attempted to use 'firebase.database' but this module could not be found.

Ensure you have installed and imported the '@react-native-firebase/database' package.
firebaseRootModuleProxy@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true...etc

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.


import RNFirebase from "@react-native-firebase/app";
import "@react-native-firebase/auth";
import "@react-native-firebase/firestore";

import {
  firebaseReducer,
  ReactReduxFirebaseProviderProps,
  ReactReduxFirebaseConfig,
  getFirebase,
} from "react-redux-firebase";
import {
  createFirestoreInstance,
  firestoreReducer,
  getFirestore,
} from "redux-firestore";
import ReduxThunk from "redux-thunk";

RNFirebase.auth().languageCode = "en";
RNFirebase.auth().settings.appVerificationDisabledForTesting = true;

const rrfConfig: ReactReduxFirebaseConfig = {
  userProfile: COLLECTIONS.USERS,
  useFirestoreForProfile: true,
  useFirestoreForStorageMeta: true,
  attachAuthIsReady: true,
  autoPopulateProfile: false,
  dispatchOnUnsetListener: false,
  dispatchRemoveAction: false,
  enableEmptyAuthChanges: false,
  enableLogging: false,
  enableRedirectHandling: false,
  firebaseStateName: "",
  logErrors: false,
  presence: false,
  preserveOnEmptyAuthChange: undefined,
  preserveOnLogout: undefined,
  resetBeforeLogin: false,
  setProfilePopulateResults: false,
  updateProfileOnLogin: false,
  onAuthStateChanged: function (
    user: any,
    _firebase: any,
    dispatch: Dispatch<AnyAction>
  ): void {
    // throw new Error("Function not implemented.");r
  },
  sessions: "",
};

const rootReducer = combineReducers({
  firebase: firebaseReducer,
  firestore: firestoreReducer,
});

const initialState = {};
const middlewares = [
  ReduxThunk.withExtraArgument({ getFirebase, getFirestore }),
];
export const store = createStore(
  rootReducer,
  initialState,
  compose(applyMiddleware(...middlewares))
);
export const rrfProps: ReactReduxFirebaseProviderProps = {
  firebase: RNFirebase,
  config: rrfConfig,
  dispatch: store.dispatch,
  createFirestoreInstance,
};
export { AppState } from "./reducers";

What is the expected behavior? I expect to save sync user with Firestore instead of database. I read the documents carefully but I think it is outdated. BTW I really appreciate your awesome work for this repo.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

{
    "react-redux-firebase": "^3.11.0",
    "redux": "^4.1.2",
    "redux-firestore": "^1.0.0",
    "redux-thunk": "^2.4.1"
}
csumrell commented 1 year ago

I am getting this same error as well trying to follow documentation on fresh setup to use firestore