1

块引用

照片(单击此处查看错误):出现错误:firestore.setListeners 不是函数

块引用

我刚刚将 redux-saga、redux-firestore 与 react-redux-firebase@2 集成在一起。. 并且它工作正常,但是当我尝试与其他组件集成时,我得到了这个错误..任何解决方案!谢谢

这是将 redux-firestore 与 react-reduc-firebase 集成的错误白色

代码:

import { compose } from 'redux'
import { connect } from 'react-redux'
// import { getFirestore } from 'redux-firestore';
import {
  firestoreConnect,
  createWithFirebase,
  withFirebase,
  firebaseConnect
} from 'react-redux-firebase'

*******
**etc**
*******

// export default Inventory;
export default compose(
// firestoreConnect([{collection: 'Invetory'}]),
  firebaseConnect(),
  connect(
    ({ firestore }) => ({
      //todos: firestore.ordered.todos,
      firestore
    })
  )
  // connect((state) => ({
  //   auth: state.firestore.auth
  // })
)(Inventory)
4

1 回答 1

1

react-redux-firebase 的作者在这里。

看起来您可能没有像react-redux-firebase 文档的 Firestore 部分中提到的那样包含导入 Firestore 。确保包含增强器、减速器和从 Firebase 导入 firestore,如下所示:

import { createStore, combineReducers, compose } from 'redux'
import firebase from 'firebase'
import 'firebase/firestore' // add this to use Firestore
import { reactReduxFirebase, firebaseReducer } from 'react-redux-firebase'
import { reduxFirestore, firestoreReducer } from 'redux-firestore'

const firebaseConfig = {}

// react-redux-firebase config
const rrfConfig = {
  userProfile: 'users',
  // useFirestoreForProfile: true // Firestore for Profile instead of Realtime DB
}

// initialize firebase instance
firebase.initializeApp(firebaseConfig) // <- new to v2.*.*

// initialize Firestore
firebase.firestore()

// Add reduxReduxFirebase and reduxFirestore enhancers when making store creator
const createStoreWithFirebase = compose(
  reactReduxFirebase(firebase, rrfConfig),
  reduxFirestore(firebase)
)(createStore)

// Add Firebase and Firestore to reducers
const rootReducer = combineReducers({
  firebase: firebaseStateReducer,
  firestore: firestoreReducer
})

// Create store with reducers and initial state
const initialState = {}
const store = createStoreWithFirebase(rootReducer, initialState)
于 2018-01-06T23:47:16.167 回答