Reactjs firebase引发此类型错误:getfirebase不是函数

Reactjs firebase引发此类型错误:getfirebase不是函数,reactjs,firebase,redux,Reactjs,Firebase,Redux,绕过firebase身份验证,但它不断抛出以下TypeError消息并中断应用程序: TypeError:getfirebase不是函数 请看一下我的商店,如果我做错了,请告诉我。 在我的商店中,我为reduxfirestore提供了getfirestore和getfirebase来响应redux firebase。我正在使用react redux firebase的v2 **store.js import rrfConfig from "../config/rrfConfig"; import

绕过firebase身份验证,但它不断抛出以下
TypeError
消息并中断应用程序:

TypeError:getfirebase不是函数

请看一下我的商店,如果我做错了,请告诉我。 在我的商店中,我为reduxfirestore提供了getfirestore和getfirebase来响应redux firebase。我正在使用react redux firebase的v2

**store.js

import rrfConfig from "../config/rrfConfig";
import { reduxFirestore, getFirestore } from "redux-firestore";
import { reactReduxFirebase, getFirebase } from "react-redux-firebase";
import { createStore, compose, applyMiddleware } from "redux";
import rootReducer from "./reducers/rootReducer";
import firebase from "firebase/app";
import "firebase/firestore";
import "firebase/auth";
import firebaseConfig from "../config/fbConfig";
import thunk from "redux-thunk";
firebase.initializeApp(firebaseConfig);
firebase.firestore();

const initialState = {};

const store = createStore(
  rootReducer,
  initialState,
  compose(
    applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
    reactReduxFirebase(firebase, rrfConfig),
    reduxFirestore(firebase)
  )
);

export default store;

**authoctions.js

export const signInAction = credentials => {
  return (dispatch, getState, { getfirebase }) => {
    const firebase = getfirebase();
    firebase
      .auth()
      .signInWithEmailAndPassword(credentials.email, credentials.password)
      .then(() => {
        dispatch({ type: "LOGIN_SUCCESS" });
      })
      .catch(err => {
        dispatch({ type: "LOGIN_ERROR", err });
      });
  };
};

**authReducer

const initialState = {
  authError: null
};

const authReducer = (state = initialState, action) => {
  switch (action.type) {
    case "LOGIN_ERROR":
      console.log("login error");
      return {
        ...state,
        authError: "login failed"
      };
    case "LOGIN_SUCCESS":
      console.log("login success");
      return {
        ...state,
        authError: null
      };
    default:
      return state;
  }
};

export default authReducer;

**减根剂

import { combineReducers } from "redux";
import authReducer from "./authReducer";
import projectReducer from "./projectReducer";
import { firestoreReducer } from "redux-firestore";
import { firebaseReducer } from "react-redux-firebase";

const rootReducer = combineReducers({
  auth: authReducer,
  project: projectReducer,
  firestore: firestoreReducer,
  firebase: firebaseReducer
});

export default rootReducer;

package.json

{
  "name": "ghandhi-land",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "firebase": "^6.0.4",
    "materialize-css": "^1.0.0-rc.2",
    "node-sass": "^4.11.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-redux": "^5.1.1",
    "react-redux-firebase": "^2.2.4",
    "react-router-dom": "^5.0.0",
    "react-scripts": "3.0.1",
    "redux": "^4.0.1",
    "redux-firestore": "^0.8.0",
    "redux-thunk": "^2.3.0"
  }
}
**符号成分

import { connect } from "react-redux";
import { signInAction } from "../../store/actions/authActions";
class SignIn extends Component {
  state = {
    email: "",
    password: " "
  };

  handleChange = e => {
    this.setState({
      [e.target.id]: e.target.value
    });
  };
  handleSubmit = e => {
    e.preventDefault();
    this.props.signIn(this.state);
  };

  render() {
    return (
      <div className="container">
        <form onSubmit={this.handleSubmit} className="white">
          <h5 className="grey-text text-darken-3">Sign In</h5>
          <div className="input-field">
            <label htmlFor="email">Email</label>
            <input type="email" id="email" onChange={this.handleChange} />
          </div>
          <div className="input-field">
            <label htmlFor="password">password</label>
            <input type="password" id="password" onChange={this.handleChange} />
          </div>
          <div className="input-field">
            <button className="btn pink lighten-1 z-depth-0">Login</button>
          </div>
        </form>
      </div>
    );
  }
}
const mapDispatchToProps = dispatch => {
  return {
    signIn: credentials => dispatch(signInAction(credentials))
  };
};

export default connect(
  null,
  mapDispatchToProps
)(SignIn);
从“react redux”导入{connect};
从“../../store/actions/authActions”导入{signInAction}”;
类签名扩展组件{
状态={
电邮:“,
密码:“
};
handleChange=e=>{
这是我的国家({
[e.target.id]:e.target.value
});
};
handleSubmit=e=>{
e、 预防默认值();
this.props.sign(this.state);
};
render(){
返回(
登录
电子邮件
暗语
登录
);
}
}
const mapDispatchToProps=调度=>{
返回{
签名:凭证=>发送(签名(凭证))
};
};
导出默认连接(
无效的
mapDispatchToProps
)(签名);

在编写redux中间件时,使用以下语句应用thunk中间件:

applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore }))
作为额外参数传递的方法的名称采用camelcase表示法:
getFirebase
getFirestore

但是,当您试图检索authoctions.js中的额外参数时,您将其分解为
getfirebase

return (dispatch, getState, { getfirebase })
您应该使用相同的符号来分解对象(在camelcase中)。因此,您的代码应该是:

return (dispatch, getState, { getFirebase })

你的代码看起来不错。你能
console.log
store.js中
getFirebase
的值吗?另外,您到底从哪里得到
TypeError
错误?是在执行
符号操作
方法时吗?当我console.log getfirebase时,它说的是
ƒgetfirebase(){if(!firebaseInstance){throw new Error('Firebase实例尚不存在。请检查编写函数。');}return firebaseInstance;}
是的,在执行signInAction@mgarcia. 为什么getfirebase没有定义?它起作用了。非常感谢你。我已经做了两天了