React-redux-firebase error 'Firebase instance does not yet exist. Check your compose function.'



我在我的项目中使用了'react-redux-firebase',并希望将firebase集成到react-thunk中。 在本地一切正常,但是将项目部署到Firebase托管时出现错误。

未捕获错误:Firebase 实例尚不存在。检查您的撰写功能。

这里有什么问题?

商店.js

import { createStore, compose, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { reduxFirestore, getFirestore } from 'redux-firestore';
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import rootReducer from './reducers/index';
import fbConfig from '../fbConfig';
/* eslint-disable no-underscore-dangle */
const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
: compose();
/* eslint-enable */
const enhancer = composeEnhancers(
applyMiddleware(
thunk.withExtraArgument({
getFirebase,
getFirestore
})
),
reduxFirestore(fbConfig),
reactReduxFirebase(fbConfig, {
useFirestoreForProfile: true,
userProfile: 'users'
})
);
const configureStore = preloadedState =>
createStore(rootReducer, preloadedState, enhancer);
const store = configureStore({});
export default store;

fbConfig.js

import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
const firebaseConfig = {
apiKey: ...,
authDomain: ...,
databaseURL: ...,
projectId: ...,
storageBucket: ...,
messagingSenderId: ...,
appId: ...
};
firebase.initializeApp(firebaseConfig);
firebase.firestore().settings({});
export default firebase;

减速器/索引

import { combineReducers } from 'redux';
import { firestoreReducer } from 'redux-firestore';
import { firebaseReducer } from 'react-redux-firebase';
import auth from './auth';
const rootReducers = combineReducers({
auth,
firestore: firestoreReducer,
firebase: firebaseReducer
});
export default rootReducers;

这是因为您没有传递reduxFirestore(fbConfig(来撰写

这可能会对您有所帮助,请检查此 github 链接 https://github.com/prescottprue/react-redux-firebase/issues/620#issuecomment-458344113

最新更新