我正在尝试使用以下代码在Redux存储中实现React-Redux-Firebase:
store.jsimport { applyMiddleware, compose, createStore } from 'redux';
import reducers from 'store/reducers';
import thunk from 'redux-thunk';
import { reduxFirestore, getFirestore } from 'redux-firestore';
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import AppConfig from 'my-app/AppConfig';
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose;
const enhancer = composeEnhancers(
applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
reduxFirestore(AppConfig.fbConfig),
reactReduxFirebase(AppConfig.fbConfig),
);
const store = createStore(reducers, enhancer); // this line generates the error message
export default store;
显然,这行:
const store = createStore(reducers, enhancer);
引发以下错误消息:
错误:v2.0.0-beta和更高版本要求传递Firebase应用程序实例或Firebase库实例。查看迁移指南以了解详细信息。
有人可以帮助我了解此错误消息的含义吗?以及我该如何解决?
答案 0 :(得分:0)
不上课。像这样使用它:
import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
var config = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
databaseURL: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
projectId: "xxxxxxxxxxxxxxxxxxxxxx",
storageBucket: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
messagingSenderId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
};
firebase.initializeApp(config);
export default firebase;