Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useFirestoreConnect stop working #1155

Open
Mihai-github opened this issue Jan 21, 2022 · 2 comments
Open

useFirestoreConnect stop working #1155

Mihai-github opened this issue Jan 21, 2022 · 2 comments

Comments

@Mihai-github
Copy link

Mihai-github commented Jan 21, 2022

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"
  },
@prescottprue
Copy link
Owner

@Mihai-github this is not an issue that I'm aware of, but haven't done a ton of testing with react-native recently - does this consistently not working for you now? Do you see any webchannel traffic? Are you able to provide a repo where the issue can be replicated?

@AxanIqbal
Copy link

same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants