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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃敟] Priority values missing from firebase realtime database DataSnapshot #7719
Comments
This does look like a bug here - I've marked it for examination That said, the modular API is already implemented in react-native-firebase and the v8 API should be considered deprecated in all cases, in all ecosystems - so using react-native-firebase for what is sort of an "extended bridge" to continue using the deprecated v8 / non-modular API is technically possible but also not technically advisable Having ported a few applications to the new style API, I can say it is almost completely mechanical. It's really just a matter of switching up the imports to import the functions (not just the desired module...) then doing a getAuth (or getApp or getNNN) first then just sending it in to the functions - but all the functions behave the same so it's just text moving around, not really functional change. Much easier than I personally feared at least |
Thanks Mike for looking at this. And thanks for the reassurance about switching to V9. I've noticed that things never turn out as bad as I fear (or as good as I hope :-) I think I'll bite the bullet and do the switcheroo. It might take a while to fix this one in RNFB. I tried looking for low-hanging fruit-- I cloned and built your repo (Great build system: I was surprised it was so easy to build such a large project and run the tests). I wrote a test case and found the line in DatabaseDataSnapshot.js where it looked like priority was not being copied into the new snap. chetstone/react-native-firebase@main...chetstone:react-native-firebase:tryfix7719 But it didn't work. |
Issue
Describe your issue here
I'm switching my app from firebase web (V8) to react-native-firebase. (I figured it would be less work to refactor than going to web V9) But I have run into a problem.
I use Priority values to store a value that indicates ordering of objects in a realtime database container, and when I read the snapshot the priorities are not there. It seems like the top-level snapshot has a priority value, but when I access the child snapshots with snap.child("child1') or snap.forEach(), the child snapshots do not contain a
.priority
property.This is the code has been working in my app for over 5 years (with added debugging printouts).
When I change the order of the counters on another device, my
.on
listener triggers and I get the following printout:This shows the top-level snap contains a
.priority
value (null) but the "Counter 44" child does not have the property at all. I can verify that the other device successfully pushed the new priorities to firebase: although the firebase console does not show priorities, I can export and download the container, and it looks like this:Is this exposing a previously unknown bug in my program, is it a bug in RNFirebase, a change in underlying FB V9+ iOS/Android libraries (It has the same problem on both platforms), or ???
react-native: 0.70.15
react-native-firebase: 19.1.1
[UPDATE:] I wondered if offline persistence might have something to do with this so I enabled persistence and found the problem remains the same either way.
[NOTE:] I filed a StackOverflow question about this but since I'm pretty sure this is a bug I decided to go ahead and file an issue. The above is a copy-paste from that SO question.
I created a reproducible demo which is here.
This is the RNFB demo with just App.tsx changed to demonstrate the issue. Since the whole setup is the default, I have not included any of my own files below (Podfile, build.gradle, etc.) Note that I only tried the RNFB demo on iOS but I have confirmed the issue is the same on Android in my app.
When running my demo, you may want to edit
make-demo.sh
so it doesn't install all the RNFB modules. The only ones needed are app and database. Also, the defaultreact-native run-ios
build fails for me. I didn't investigate, I always prefer to use xcode. I just opened up xcode and ran on the simulator with no problemProject Files
Javascript
Click To Expand
package.json
:# N/A
firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:19.1.1
Firebase
module(s) you're using that has the issue:database
TypeScript
?N
&VERSION
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: