Skip to content

useFirestoreConnect stop working #1155

@Mihai-github

Description

@Mihai-github

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

  • Bug

(If this is a usage question, please do not post it here—post it on gitter. If this is not a “feature” or a “bug”, or the phrase “How do I...?” applies, then it's probably a usage question.)

What is the current behavior?

I've managed 2 days ago to integrate firebase and also firestore and also added the firebase and firestore reducers. At first all looked like working but after some time w/o any known reason using useFirestoreConnect(['todos']) // sync todos collection from Firestore into redux for listening to a collection to see that everything okei and that the firestore reducers is in sync the listener stop working.
I've also enabled the setLogLevel("debug") to see that the webchanel is created and as I said above it works but for an unknown reason stopped working and seems inconsistent and weird. It would be really nice to not manage the listener manually and also make my own reducers to keep the data added to the collections that I'm interested in watching.
With "manual listener" till now seems to work but would be nice to now depend on it because I would have to make my own reducers... maybe someone knows the issue or something that could help.

If it's some known issue with the custom hook or someone can help would be relly nice :)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

Added the hook inside the App.tsx and watch the console if the reducers gets populated and the connection started between the application and firestore.

With hook

useFirestoreConnect(['users'])
const users = useSelector((state) => state.firestore.data.users)

Manual

useEffect(() => {
    const subscriber = firestore()
      .collection('users')
      .onSnapshot(documentSnapshot => {
        console.log('User data: ', documentSnapshot);
      });

    // Stop listening for updates when no longer required
    return () => subscriber();
  }, []);

What is the expected behavior?

The expected behavior is as I said the custom hook to work and listen to a specific collection and also populate the reducer as previously did and now not doing w/o any known reason.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

### I'm working on a react-native env not web.

"dependencies": {
    "@react-native-firebase/app": "^14.2.2",
    "@react-native-firebase/auth": "^14.2.2",
    "@react-native-firebase/firestore": "^14.2.2",
    "@react-native-firebase/messaging": "^14.2.2",
    "@react-native-firebase/storage": "^14.2.2",
    "@reduxjs/toolkit": "^1.7.1",
    "@types/react-redux": "^7.1.22",
    "@types/redux-logger": "^3.0.9",
    "firebase": "^9.6.3",
    "react": "17.0.2",
    "react-native": "0.66.4",
    "react-redux": "^7.2.6",
    "react-redux-firebase": "^3.11.0",
    "redux-firestore": "^0.15.2",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "redux-saga-firebase": "^0.15.0",
    "reselect": "^4.1.5"
  },

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions