我是使用上述 2 个库的初学者。我的云 Firestore 上有一些虚拟员工数据,我想使用 react-redux-firebase 和 redux-firestore 获得这些数据。
我已经配置了 redux 存储并添加了 reducer,但在我的 redux 状态下没有员工数据可见。我的代码中没有任何错误。任何人都可以帮忙吗?谢谢
我的代码框链接如下...这是我创建的一个非常基本的应用程序,用于试用上述库
https://codesandbox.io/live/VOxppz
我的 Firebase 设置
import firebase from "firebase";
import "firebase/firestore";
const firebaseConfig = {
apiKey: "AIzaSyD564gkWOpSYks8wxOmWNwGsG-555uvBDg",
authDomain: "test-3babb.firebaseapp.com",
databaseURL: "https://test-3babb.firebaseio.com",
projectId: "test-3babb",
storageBucket: "test-3babb.appspot.com",
messagingSenderId: "911931804634"
};
firebase.initializeApp(firebaseConfig);
firebase.firestore();
export default firebase;
我的 Redux 商店
import { createStore, applyMiddleware, compose } from "redux";
import thunk from "redux-thunk";
import { reactReduxFirebase, getFirebase } from "react-redux-firebase";
import { reduxFirestore, getFirestore } from "redux-firestore";
import firebase from "../../config/firebase";
import rootReducer from "../reducers";
// Refer to App.js for wrapping of App component
const rrfConfig = {
userProfile: "users",
attachAuthIsReady: true,
useFirestoreForProfile: true
};
export const configureStore = preloadedState => {
const middlewares = [thunk.withExtraArgument({ getFirebase, getFirestore })];
const middlewareEnhancer = applyMiddleware(...middlewares);
const storeEnhancers = [middlewareEnhancer];
const composedEnhancer = compose(
...storeEnhancers,
reactReduxFirebase(firebase, rrfConfig),
reduxFirestore(firebase)
);
const store = createStore(rootReducer, preloadedState, composedEnhancer);
return store;
};
我的 Redux 减速器
import { combineReducers } from "redux";
import { firebaseReducer } from "react-redux-firebase";
import { firestoreReducer } from "redux-firestore";
import authReducers from "./authReducers";
export default combineReducers({
auth: authReducers,
firebase: firebaseReducer,
firestore: firestoreReducer
});