初始化Firestore时遇到问题。 这是代码:
在store.js中
import { combineReducers, compose, createStore } from 'redux';
import firebase from 'firebase';
import 'firebase/firestore';
import { reactReduxFirebase, firebaseReducer } from 'react-redux-firebase';
import { reduxFirestore, firestoreReducer } from 'redux-firestore';
//Reducers
const firebaseConfig = {};
// react-redux-firebase config
const rrfConfig = {
userProfile: 'users',
useFirestoreForProfile: true,
};
//init firebase instance
firebase.initializeApp(firebaseConfig);
//init firestore
const firestore = firebase.firestore();
//adding reactReduxFirebase enhencer
firebase.firestore(); // <- needed if using firestore
const rootReducer = combineReducers({
firebase: firebaseReducer,
firestore: firestoreReducer,
});
//create initial state
const initialState = {};
const store = createStore(
rootReducer,
initialState,
compose(
reactReduxFirebase(firebase),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
);
export default store;
在App.js中
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { Provider } from 'react-redux';
import store from './store';
function App() {
return (
<Provider store={store}>
<Router>
<div className="App">
<AppNavbar></AppNavbar>
<Switch>
<Route exact path="/" component={Dashboard} />
</Switch>
</div>
</Router>
</Provider>
);
}
export default App;
这是错误日志 | //创建初始状态 40 | 41 | const initialState = {};
42 | const store = createStore( 43 | rootReducer, 44 | initialState, 45 | compose(reactReduxFirebase(firebase))
感谢您的帮助。
答案 0 :(得分:0)
问题特别在于调用reactReduxFirebase
,因为它不是函数。
我对'react-redux-firebase'软件包不太熟悉,但是看来this function was removed是最新版本。
现在建议不要将应用程序包装在ReactReduxFirebaseProvider
中,而不是在商店中应用此增强器。