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

Unable to fetch data from firebase but can save data to firebase #1407

Closed
Oshianor opened this issue Aug 15, 2018 · 17 comments
Closed

Unable to fetch data from firebase but can save data to firebase #1407

Oshianor opened this issue Aug 15, 2018 · 17 comments
Assignees
Labels
Milestone

Comments

@Oshianor
Copy link

Issue

Environment

  1. Application Target Platform:
both
  1. Development Operating System:
windows 10
  1. Build Tools:
Android Studio
  1. React Native version:
0.55
  1. React Native Firebase Version:
4.3.8
  1. Firebase Module:
database, auth, core
  1. Are you using typescript?
no

Loving react-native-firebase? Please consider supporting them with any of the below:

@Oshianor
Copy link
Author

Whenever i run this code i get no response unless am just starting the android dev server . Even when i reload my app it still doesnt work.
firebase.database().ref('post').once('value').then(res => console.log(res))

screenshot 27
screenshot 28
screenshot 29
screenshot 30

@Ehesp
Copy link
Member

Ehesp commented Aug 17, 2018

Can we see your code usage please? Those screenshots don't really help sorry!

But, failure to read data on both platforms to me would indicate that this is perhaps an issue with your database rules on the Firebase consoles - check your rules, the default ones, for example, require a user to be authenticated.


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

@Salakar Salakar added platform: android platform: ios plugin: database Firebase Realtime Database Workflow: Waiting for User Response Blocked waiting for user response. labels Aug 17, 2018
@Oshianor
Copy link
Author

My database rules are well setup. After much testing i think i understand what the problem is but i have no ideal how to fix it. Whenever i start up my react native android server when my screens are loaded some times they fetch the data while others they don't and that point i have to manually close the app and open it again. NOTE : The android server keeps running while i close the app.

@stale
Copy link

stale bot commented Sep 14, 2018

Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added Type: Stale Issue has become stale - automatically added by Stale bot and removed Type: Stale Issue has become stale - automatically added by Stale bot labels Sep 14, 2018
@Salakar Salakar added the Type: Stale Issue has become stale - automatically added by Stale bot label Sep 15, 2018
@armanatz
Copy link

@Ehesp I seem to also be running into the same issue. I am trying to run the same code as @Oshianor but unless I close the application on my emulator and open it again, the code only executes once and never executes again upon subsequent refreshes.

I am running on [email protected] and [email protected]

Any ideas?

@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label Sep 27, 2018
@Salakar Salakar added this to the v5.0.1+ milestone Sep 27, 2018
@KennethSJiang
Copy link

having the same issue here. Didn't have this problem when using web based firebase npm

@csgonutty
Copy link

Same issue here, I have to restart the app and emulator in order for the .on() listener to fire.

Im running [email protected] and [email protected]

@Salakar Salakar self-assigned this Oct 7, 2018
@dantman
Copy link

dantman commented Oct 10, 2018

I was going to report the same issue. React Native Firebase works, but then on Android after a few JS reloads it stops working.

I'm using react-redux-firebase, however I did include this code in my app to verify that this issue is actually in react-native-firebase and not in react-redux-firebase:

firebase.firestore().collection('practice').get()
	.then(data => console.log(data.docs[0].data()))
	.catch(console.error);

Of particular note. I notice that when it's working I get data; when it fails I get no response at all. i.e. It does not fail with an error, it simply never resolves the promise.

And it doesn't start working again until I force quit the app and reopen it.

@Salakar Salakar modified the milestones: v5.0.1+, v5.1.0 Oct 21, 2018
@kamicodaxe
Copy link

The same issue here. Database works on the first load but stops working after dev app refreshes. I observed this issue after updating to RNFIrebase v5.0.0

@gitsad
Copy link

gitsad commented Oct 23, 2018

I have got the same problem. I need to reload whole app to receive the data on componentDidMount

@reaction reaction bot deleted a comment from irekrog Oct 24, 2018
@Salakar
Copy link
Member

Salakar commented Oct 27, 2018

Hey all, this should be fixed as part of #1619 - you can give it a go on [email protected] - see the rc1 release notes on GH for the correct Native SDK versions.

For firestore could you please raise a seperate issue so I can track it and work on it there.


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

@Salakar Salakar closed this as completed Oct 27, 2018
@tzurae
Copy link

tzurae commented Mar 11, 2019

same here still

@silvafacundo
Copy link

I'am having the same problem. I was using the latest react-native-firebase version but then i read that downgrading to 5.2.0 solves the problem. It Solves it until syntax error, once i fix my bundling problem firebase database stops working...
I'm using react-native 0.59.2
On windows 10 and developing for android

@anastely
Copy link

@silvafacundo I have the same problem but with "react-native-firebase": "4.3.8",
and I think the syntax is true,

displayCategories = () => {
    const refData = firebase.database().ref("categories");
    var items = [];
    refData.once("value", snapshot => {
      console.log(snapshot.val());
      snapshot.forEach((childSnapshot) => {
        items.push({
          id: childSnapshot.val().id,
          name: childSnapshot.val().name,
        });
      });
      this.setState({ categories: items })
    });
  }

if you solve the problem please tell me!

@silvafacundo
Copy link

@silvafacundo I have the same problem but with "react-native-firebase": "4.3.8",
and I think the syntax is true,

displayCategories = () => {
    const refData = firebase.database().ref("categories");
    var items = [];
    refData.once("value", snapshot => {
      console.log(snapshot.val());
      snapshot.forEach((childSnapshot) => {
        items.push({
          id: childSnapshot.val().id,
          name: childSnapshot.val().name,
        });
      });
      this.setState({ categories: items })
    });
  }

if you solve the problem please tell me!

@anastely I think that the problem is coming from Debuggin JS Remotely. I've managed to get it working by not using that option. Debbugin is pretty tedious, but that was the only solution I've could find

@anastely
Copy link

@silvafacundo uh oh, it's work after uninstalling the app and stoped Debugging JS Remotely,
but now it's not real-time after delete or insert data I don't see any update on my app and change the .once into .on , any idea?

@silvafacundo
Copy link

@anastely Uhmmm... for me it's working fine, make sure that you are updating the correct path, and that is updating at console.firebase.google.com.
If it isn't updating, catch for errors of all your firebase database references and check your database rules.
If you want attach your files and database structure and rules so I can have a better idea

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

No branches or pull requests