-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
docs: deprecation guide for moving to firebase-js-sdk v9 modular API #8279
base: main
Are you sure you want to change the base?
Changes from all commits
686c181
17d15c7
6146c06
407fce2
5e51972
01a29fa
4fa0db8
6e52cb8
ad647c5
92e1332
317f2d3
357d1d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: Migrating to v22 | ||
description: Migrate to React Native Firebase v22. | ||
previous: / | ||
next: /typescript | ||
--- | ||
|
||
# Switching off warning logs | ||
|
||
You may notice an influx of console warning logs as we continue deprecating all existing namespaced API. If you would like to switch these logs off, you may set the following global property to `true` anywhere before you initialize Firebase. | ||
|
||
```js | ||
globalThis.RNFB_SILENCE_V8_DEPRECATION_WARNINGS = true; | ||
``` | ||
|
||
# Migrating to React Native modular API | ||
|
||
React Native Firebase does not currently have documentation for modular API. A refresh of the React Native Firebase documentation is something we will be aiming to achieve in the near future. We're keen to move the project to TypeScript which will then allow us to generate reference documentation from those types. | ||
|
||
However, if you are familiar with the Firebase JS SDK, it will be a much smoother process. React Native Firebase is using the same API as can be found on the official [Firebase JS SDK modular API documentation](https://firebase.google.com/docs/reference/js). | ||
|
||
## Firestore Deprecation Example | ||
|
||
### Namespaced (deprecated) Query | ||
|
||
You ought to move away from the following way of making Firestore queries. The React Native Firebase namespaced API is being completely removed in React Native Firebase v22: | ||
|
||
```js | ||
import firestore from '@react-native-firebase/firestore'; | ||
|
||
const db = firestore(); | ||
|
||
const querySnapshot = await db.collection('cities').where('capital', '==', true).get(); | ||
|
||
querySnapshot.forEach(doc => { | ||
console.log(doc.id, ' => ', doc.data()); | ||
}); | ||
``` | ||
|
||
### Modular Query | ||
|
||
This is how the same query would look using the new, React Native Firebase modular API: | ||
|
||
```js | ||
import { collection, query, where, getDocs, getFirestore } from '@react-native-firebase/firestore'; | ||
|
||
const db = getFirestore(); | ||
|
||
const q = query(collection(db, 'cities'), where('capital', '==', true)); | ||
|
||
const querySnapshot = await getDocs(q); | ||
|
||
querySnapshot.forEach(doc => { | ||
console.log(doc.id, ' => ', doc.data()); | ||
}); | ||
``` | ||
|
||
For more examples of requesting Firestore data, see the official Firebase documentation for [Get data with Cloud Firestore](https://firebase.google.com/docs/firestore/query-data/get-data). | ||
|
||
### Migration Help | ||
|
||
You will find code snippets for "Web namespaced API" and "Web modular API" throughout the official Firebase documentation. Update your code to use "Web modular API". Here are some links to help you get started: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is fantastic |
||
|
||
- [Firestore](https://firebase.google.com/docs/firestore/quickstart) | ||
- [Auth](https://firebase.google.com/docs/auth/web/start) | ||
- [RTDB](https://firebase.google.com/docs/database/web/start) | ||
- [Storage](https://firebase.google.com/docs/storage/web/start) | ||
- [Remote Config](https://firebase.google.com/docs/remote-config/get-started?platform=web) | ||
- [Messaging](https://firebase.google.com/docs/cloud-messaging/js/client) | ||
- [Functions](https://firebase.google.com/docs/functions/callable) | ||
- [App Check](https://firebase.google.com/docs/app-check/web/recaptcha-provider) | ||
- [Analytics](https://firebase.google.com/docs/analytics/get-started) | ||
- [Perf](https://firebase.google.com/docs/perf-mon/get-started-web) | ||
- [Crashlytics](https://github.com/invertase/react-native-firebase/blob/main/packages/crashlytics/lib/modular/index.d.ts) (Crashlytics doesn't exist on Firebase web, this is a link to the type declarations which contains all methods available). |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -214,8 +214,8 @@ const mapOfDeprecationReplacements = { | |||||
}; | ||||||
|
||||||
const v8deprecationMessage = | ||||||
'This v8 method is deprecated and will be removed in the next major release ' + | ||||||
'as part of move to match Firebase Web modular v9 SDK API.'; | ||||||
'This method is deprecated (as well as all React Native Firebase namespaced API) and will be removed in the next major release ' + | ||||||
'as part of move to match Firebase Web modular v9 SDK API. Please see migration guide for more details: https://rnfirebase.io/migrating-to-v22'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was called out as confusing - using "v9" at all - js-sdk is on v11 now anyway, and was it v9 of react-native-firebase, but we're going to v21? With enough context it makes sense but I think just strictly using "namespaced" and "non-modular" is good enough
Suggested change
|
||||||
|
||||||
export function deprecationConsoleWarning(nameSpace, methodName, instanceName, isModularMethod) { | ||||||
if (!isModularMethod) { | ||||||
|
@@ -225,8 +225,11 @@ export function deprecationConsoleWarning(nameSpace, methodName, instanceName, i | |||||
const deprecatedMethod = instanceMap[methodName]; | ||||||
if (instanceMap && deprecatedMethod) { | ||||||
const message = createMessage(nameSpace, methodName, instanceName); | ||||||
// eslint-disable-next-line no-console | ||||||
console.warn(message); | ||||||
|
||||||
if (!globalThis.RNFB_SILENCE_V8_DEPRECATION_WARNINGS) { | ||||||
// eslint-disable-next-line no-console | ||||||
console.warn(message); | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
|
@@ -367,6 +370,8 @@ export function warnIfNotModularCall(args, replacementMethodName = '') { | |||||
message += ` Please use \`${replacementMethodName}\` instead.`; | ||||||
} | ||||||
|
||||||
// eslint-disable-next-line no-console | ||||||
console.warn(message); | ||||||
if (!globalThis.RNFB_SILENCE_V8_DEPRECATION_WARNINGS) { | ||||||
// eslint-disable-next-line no-console | ||||||
console.warn(message); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how much guide we really need? Upstream is pretty thin. I link it here then add a rough explanation and I think that's a "guide" really. No need to talk about the future typescript plans or anything, just "here's the idea, here's an upstream link, get it done" ?