0
votes

I am using react-native with Firestore 5.2.0 but the error is regarding the update of Firestore to 5.0.4.

The error is:

The behaviour for date objects stored in Firestore is going to change and your app may break. To hide this warning and ensure your app does not break, you need to add the following code to your app before calling other cloud Firestore methods:

const firestore= firebase.firestore();
const settings ={ /*your settings */ timestampInSnapshots: true};
firestore.settings(settings);

Can anyone help me out how can I get out of this error?

Thanks

Firebase error

2
Did you check out some of the other questions mentioning that error? stackoverflow.com/… - Frank van Puffelen
Thankyou @frank...Yes, I have checked all the other questions that were posted earlier...but none of them gave the answer that is related to the error..Can you please help me out? - Kalyani Pullela
Sorry, but that seems very unlikely. The message is quite specific, so I'd expect those questions to be about the same message. The message also is quite explicit about what you need to do. What have you already tried? - Frank van Puffelen
@FrankvanPuffelen, I've found a solution for it.... - Kalyani Pullela
Good to hear Kalyani. If you can post that as an answer, including the code changes you made, that answer might be helpful to others who are confused by the error message. - Frank van Puffelen

2 Answers

5
votes
firebase.initializeApp({
  apiKey: "AIzaSyCPW020BADuNGvwOPhad4XSq_UYVK3OSxM",
  authDomain: "firestorecrud-b08be.firebaseapp.com",
  databaseURL: "https://firestorecrud-b08be.firebaseio.com",
  projectId: "firestorecrud-b08be",
  storageBucket: "firestorecrud-b08be.appspot.com",
  messagingSenderId: "742054197796"
});

const settings = {timestampsInSnapshots: true};

firebase.firestore().settings(settings);

Just add the above two statements in your code where you are configuring your firebase/firestore code.

0
votes

Update as of March, 2019

For versions 5.8.0 or above

You should not be getting this error anymore.

In Version 5.8.0 - Jan 17, 2019 there were some breaking changes introduced:

BREAKING: The timestampsInSnapshots setting is now enabled by default. Now, timestamp fields read from a DocumentSnapshot will be returned as Timestamp objects instead of Date. Any code expecting to receive a Date object must be updated.

Note: As stated in the official docs, timestampsInSnapshots is going to be removed in a future release so make sure to remove it altogether.

For older versions (5.7.2 and below)

This should do the work:

firebase.firestore().settings({ timestampsInSnapshots: true });