繁体   English   中英

TypeError: Object(...) 不是 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;

这是错误日志 | //创建初始值 state 40 | 41 | const 初始状态 = {};

42 | const store = createStore( 43 | rootReducer, 44 | initialState, 45 | compose(reactReduxFirebase(firebase))

任何帮助表示赞赏。

问题特别在于调用reactReduxFirebase ,因为它不是 function。

我不太熟悉 'react-redux-firebase' package,但似乎这个 function 已从最新版本中删除。

现在建议您将应用程序包装在ReactReduxFirebaseProvider中,而不是将此增强器应用于您的商店。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM