prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

TypeErro: Object(...) is not a function when calling `useFirestoreConnect` #965

Open AWIXOR-zz opened 4 years ago

AWIXOR-zz commented 4 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

I'm using react-redux-firebase and redux-firestore packages. I'm trying to connect firestore to redux using the useFirestoreConnect hook, but after calling this hook it gives me a TypeError like in this picture.

image

image

I've searched in the GitHub issues and docs but I'vent fount any solution.

The error is occurred when calling the useFirestoreConnect hook.

 const userId = useSelector((state) => state.firebase.auth.uid);
  useFirestoreConnect([
    {
      collection: "products",
      doc: userId,
    },
  ]);

Versions of dependencies

    "firebase": "^7.15.0",
    "react": "^16.13.1",
    "react-redux": "^7.2.0",
    "react-redux-firebase": "^3.5.1",
    "redux": "^4.0.5",
    "redux-firestore": "^0.13.0",
prescottprue commented 3 years ago

It is good to check for the existence of that user id before using it as part of the query since it takes time to load auth into state, could you see if the following helps solve your issue?:

  useFirestoreConnect(userId && [
    {
      collection: "products",
      doc: userId,
    },
  ]);