“TypeError: Object(…) is not a function” react-redux-firebase

杀马特。学长 韩版系。学妹 提交于 2020-03-13 09:41:04

问题


I'm trying to create a project in React and I'm using Firebase. In my react-redux-firebase project one line of code making error but I couldn't fix that. How could I fix this "TypeError: Object(...) is not a function"

I have searched for this problem but couldn't fix the problem.

I'm following a tutorial where the react version is 16.4.1. I'm not sure this is the problem or not

index.js file

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { createStore, applyMiddleware, compose } from "redux";
import rootReducer from "./store/reducers/rootReducer";
import { Provider } from "react-redux";
import thunk from "redux-thunk";
import { reduxFirestore, getFirestore } from "redux-firestore";
import { reactReduxFirebase, getFirebase } from "react-redux-firebase";
import fbConfig from "./config/fbConfig";

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

if I comment out the reatReduxFirebase() then it works fine but I need this to work

You could find all codes here: https://github.com/martuza-shimul/React-Blog-app

I'm getting this error every time:

TypeError: Object(...) is not a function
Module../src/index.js
i:/Learning new things/react/pma/src/index.js:17
  14 | const store = createStore(
  15 |   rootReducer,
  16 |   compose(
> 17 |     applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
  18 |     reduxFirestore(fbConfig),
  19 |     reactReduxFirebase(fbConfig)
  20 |  

I'm not sure how to fix this. A little bit of help/hint really be appreciated.


回答1:


Please use this npm packages
npm packages compatibility issue

npm i --save react-redux@5.1.1 react-redux-firebase@2.2.4




回答2:


This is a react-redux-firebase v2.x.x coding pattern and you probably have v3.x.x installed.

  1. Check which version of react-redux-firebase you are using:
    npm ls react-redux-firebase
  1. If the version is 3.0.0 or higher, you need to migrate your code to the new coding pattern. See React-Redux-Firebase v3.x.x Migration Guide for detailed instructions.


来源:https://stackoverflow.com/questions/58709826/typeerror-object-is-not-a-function-react-redux-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!