2
votes

I have ran into a weird problem. So I am using React Native in combination with Firebase. Up until recently I had no problem but today I have this bug where the Timestamps are becoming null.

Here is what it looks like in my Firebase console:

Inside Firebase Console

Here is what it looks like on the React.js web app connected to the same Firebase Firestore:

Inside React Web App

However when I do remote debugging on my React Native app, this is what gets logged out:

enter image description here

I don't really have any relevant code snippet to post because on both the web app and the React Native app I just get the data from the Firestore and then just add them in my Redux store. Nothing else fancy or special is done with it.

2
I'm encountering the same issue, using react-native-firebase. It was working fine, then I upgraded to version 5.2.2 and suddenly all timestamps are null. - Zac

2 Answers

2
votes

I solved this by downgrading my Firebase/Core and Firebase/Firestore dependencies from 5.16 to 5.15 (which is the version recommended by React Native Firebase’s installation guide anyway).

Here are the steps that worked for me:

  1. Assuming you're using CocoaPods, change your Podfile to:

    pod 'Firebase/Core', '~> 5.15.0'
    pod 'Firebase/Firestore', '~> 5.15.0'
    

    (Also be sure to update the versions of any other Firebase/* pods.)

  2. From your ios/ folder, run pod install

  3. Restart your project in XCode (or on the command line with react-native run-ios)

1
votes

Did you upgrade your firebase SDK recently? Firebase Firestore recently changed so that Firestore reads back Firebase Timestamp objects instead of system date objects.

From Firebase's SDK warning

/** So you will also
need to update code expecting a Date to instead expect a Timestamp. For example:*/

  // Old:
  const date = snapshot.get('created_at');
  // New:
  const timestamp = snapshot.get('created_at');
  const date = timestamp.toDate();