react-redux-firebase error'Firebase实例尚不存在.检查您的撰写功能." [英] react-redux-firebase error 'Firebase instance does not yet exist. Check your compose function.'

查看:68
本文介绍了react-redux-firebase error'Firebase实例尚不存在.检查您的撰写功能."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用"react-redux-firebase",并希望将firebase集成到react-thunk中.在本地一切正常,但是将项目部署到Firebase托管时出现错误.

I'm using 'react-redux-firebase' in my project and want to integrate firebase into react-thunk. Everything works fine on local but I got error when deploy project to Firebase hosting.

未捕获的错误:Firebase实例尚不存在.检查您的撰写功能.

这是什么问题?

store.js

import { createStore, compose, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { reduxFirestore, getFirestore } from 'redux-firestore';
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';

import rootReducer from './reducers/index';
import fbConfig from '../fbConfig';

/* eslint-disable no-underscore-dangle */
const composeEnhancers =
  process.env.NODE_ENV !== 'production' &&
  typeof window === 'object' &&
  window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
    ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
    : compose();
/* eslint-enable */

const enhancer = composeEnhancers(
  applyMiddleware(
    thunk.withExtraArgument({
      getFirebase,
      getFirestore
    })
  ),
  reduxFirestore(fbConfig),
  reactReduxFirebase(fbConfig, {
    useFirestoreForProfile: true,
    userProfile: 'users'
  })
);

const configureStore = preloadedState =>
  createStore(rootReducer, preloadedState, enhancer);

const store = configureStore({});

export default store;

fbConfig.js

import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';

const firebaseConfig = {
  apiKey: ...,
  authDomain: ...,
  databaseURL: ...,
  projectId: ...,
  storageBucket: ...,
  messagingSenderId: ...,
  appId: ...
};

firebase.initializeApp(firebaseConfig);
firebase.firestore().settings({});

export default firebase;

减速器/索引

import { combineReducers } from 'redux';
import { firestoreReducer } from 'redux-firestore';
import { firebaseReducer } from 'react-redux-firebase';

import auth from './auth';

const rootReducers = combineReducers({
  auth,
  firestore: firestoreReducer,
  firebase: firebaseReducer
});

export default rootReducers;

推荐答案

这是因为您没有通过reduxFirestore(fbConfig)进行编写

It is because you don't pass reduxFirestore(fbConfig) to compose

这可能对您有帮助,请检查此github链接 https://github.com/prescottprue/react-redux-firebase/issues/620#issuecomment-458344113

This might help you, Check this github link https://github.com/prescottprue/react-redux-firebase/issues/620#issuecomment-458344113

这篇关于react-redux-firebase error'Firebase实例尚不存在.检查您的撰写功能."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆