TypeError: Object(...) is not a function (anonymous function)
TypeError: Object(...) is not a function (anonymous function)
初始化 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))
感谢任何帮助。
问题出在调用 reactReduxFirebase
上,因为它不是函数。
我对 'react-redux-firebase' 包不太熟悉,但似乎 this function was removed 来自最新版本。
现在建议您将应用包装在 ReactReduxFirebaseProvider
.
中,而不是将此增强器应用于您的商店
初始化 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))
感谢任何帮助。
问题出在调用 reactReduxFirebase
上,因为它不是函数。
我对 'react-redux-firebase' 包不太熟悉,但似乎 this function was removed 来自最新版本。
现在建议您将应用包装在 ReactReduxFirebaseProvider
.