-
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 modular API #8279
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
686c181
docs: deprecation guide for moving to v9 modular API
russellwheatley 17d15c7
chore: hide warning logs from another function
russellwheatley 6146c06
docs: update spacing
russellwheatley 407fce2
chore: remove console log
russellwheatley 5e51972
docs: tweak
russellwheatley 01a29fa
docs: update links
russellwheatley 4fa0db8
docs: add migration guide to docs
russellwheatley 6e52cb8
docs: full stop
russellwheatley ad647c5
chore: update deprecation log with link to migration guide
russellwheatley 92e1332
docs: update migration guide
russellwheatley 317f2d3
chore:format
russellwheatley 357d1d8
docs: fix spelling
russellwheatley 20de302
Apply suggestions from code review
mikehardy c89d5da
style: `yarn lint:markdown`
mikehardy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
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 | ||
|
||
If you are familiar with the Firebase JS SDK, the upgrade will be a familiar process, following similar steps to [the migration guide](https://firebase.google.com/docs/web/modular-upgrade#refactor_to_the_modular_style) for firebase-js-sdk. | ||
|
||
React Native Firebase uses the same API as the official [Firebase JS SDK modular API documentation](https://firebase.google.com/docs/reference/js) so the same migration steps apply here, except there is no need for special "compat" imports as an intermediate step. | ||
|
||
The process will always follow the same steps for every API you use: | ||
|
||
- determine the new modular API function for the old namespaced API you are using | ||
- import that new modular API function | ||
- change the call from using the firebase module to access the API and passing parameters, to the new style of using the modular API function, passing in the firebase module object(s) required for it to work and then the parameters. | ||
|
||
In the end, it should be a very mechanical process and can be done incrementally, one API call at a time. | ||
|
||
There are concrete examples below to show the process | ||
|
||
## 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: | ||
|
||
- [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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is fantastic