Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/migrating-to-v23.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Migrating to v23
description: Migrate to React Native Firebase v23.
previous: /migrate-to-v22
next: /typescript
next: /migrate-to-v24
---

# Firebase Crashlytics
Expand Down
41 changes: 41 additions & 0 deletions docs/migrating-to-v24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Migrating to v24
description: Migrate to React Native Firebase v24.
previous: /migrate-to-v23
---

# Firestore

Version 24 introduces `withConverter` functionality from Firebase JS SDK. Due to the differences in types between references and queries in namespace vs modular API, you will need to make the following changes:

### modular API

Modular reference and query types have been updated to support input of two generic types (`AppModelType`, `DbModelType`). Additionally, to match the JS SDK, they are now exported separately at the root, instead of through `FirebaseFirestoreTypes`.

Most commonly these types will be affected: `CollectionReference`, `DocumentReference`, `DocumentSnapshot`, `QueryDocumentSnapshot`, `QuerySnapshot`, `Query`.

```js
// Previously
import { doc, getFirestore, onSnapshot, FirebaseFirestoreTypes } from '@react-native-firebase/firestore';

onSnapshot(doc(getFirestore(), 'foo', 'foo'), {
next: (snapshot: FirebaseFirestoreTypes.DocumentSnapshot) => {
console.log(snapshot.get('foo'));
},
});
```

```js
// Now
import { doc, getFirestore, onSnapshot, DocumentSnapshot } from '@react-native-firebase/firestore';

onSnapshot(doc(getFirestore(), 'foo', 'foo'), {
next: (snapshot: DocumentSnapshot) => {
console.log(snapshot.get('foo'));
},
});
```

### namespace API

No changes required for older namespace API.
2 changes: 2 additions & 0 deletions docs/sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- '/migrating-to-v22'
- - Migration Guide to v23
- '/migrating-to-v23'
- - Migration Guide to v24
- '/migrating-to-v24'
- - TypeScript
- '/typescript'
- - Platforms
Expand Down
2 changes: 1 addition & 1 deletion docs/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: TypeScript
description: Using TypeScript with React Native Firebase
next: /other-platforms
previous: /migrating-to-v22
previous: /migrating-to-v24
---

The React Native Firebase project comes with support for TypeScript. The project provides
Expand Down
20 changes: 20 additions & 0 deletions packages/firestore/__tests__/firestore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => getCountFromServer(query),
// @ts-expect-error Combines modular and namespace API
() => query.count(),
'count',
);
Expand All @@ -958,6 +959,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => getCountFromServer(query),
// @ts-expect-error Combines modular and namespace API
() => query.countFromServer(),
'countFromServer',
);
Expand All @@ -970,6 +972,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => endAt('foo'),
// @ts-expect-error Combines modular and namespace API
() => query.endAt('foo'),
'endAt',
);
Expand All @@ -982,6 +985,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => endBefore('foo'),
// @ts-expect-error Combines modular and namespace API
() => query.endBefore('foo'),
'endBefore',
);
Expand All @@ -994,6 +998,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => getDocs(query),
// @ts-expect-error Combines modular and namespace API
() => query.get(),
'get',
);
Expand All @@ -1007,6 +1012,7 @@ describe('Firestore', function () {
collectionRefV9Deprecation(
// no equivalent method
() => {},
// @ts-expect-error Combines modular and namespace API
() => query.isEqual(query),
'isEqual',
);
Expand All @@ -1019,6 +1025,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => limit(9),
// @ts-expect-error Combines modular and namespace API
() => query.limit(9),
'limit',
);
Expand All @@ -1031,6 +1038,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => limitToLast(9),
// @ts-expect-error Combines modular and namespace API
() => query.limitToLast(9),
'limitToLast',
);
Expand All @@ -1043,6 +1051,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => onSnapshot(query, () => {}),
// @ts-expect-error Combines modular and namespace API
() => query.onSnapshot(() => {}),
'onSnapshot',
);
Expand All @@ -1055,6 +1064,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => orderBy('foo', 'asc'),
// @ts-expect-error Combines modular and namespace API
() => query.orderBy('foo', 'asc'),
'orderBy',
);
Expand All @@ -1067,6 +1077,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => startAfter('foo'),
// @ts-expect-error Combines modular and namespace API
() => query.startAfter('foo'),
'startAfter',
);
Expand All @@ -1079,6 +1090,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => startAt('foo'),
// @ts-expect-error Combines modular and namespace API
() => query.startAt('foo'),
'startAt',
);
Expand All @@ -1091,6 +1103,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => where('foo', '==', 'bar'),
// @ts-expect-error Combines modular and namespace API
() => query.where('foo', '==', 'bar'),
'where',
);
Expand All @@ -1103,6 +1116,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => addDoc(query, { foo: 'bar' }),
// @ts-expect-error Combines modular and namespace API
() => query.add({ foo: 'bar' }),
'add',
);
Expand All @@ -1115,6 +1129,7 @@ describe('Firestore', function () {

collectionRefV9Deprecation(
() => doc(query, 'bar'),
// @ts-expect-error Combines modular and namespace API
() => query.doc('foo'),
'doc',
);
Expand All @@ -1140,6 +1155,7 @@ describe('Firestore', function () {
const docRef = firestore.doc('some/foo');

docRefV9Deprecation(
// @ts-expect-error Combines modular and namespace API
() => deleteDoc(docRef),
() => docRef.delete(),
'delete',
Expand All @@ -1152,6 +1168,7 @@ describe('Firestore', function () {
const docRef = firestore.doc('some/foo');

docRefV9Deprecation(
// @ts-expect-error Combines modular and namespace API
() => getDoc(docRef),
() => docRef.get(),
'get',
Expand All @@ -1177,6 +1194,7 @@ describe('Firestore', function () {
const docRef = firestore.doc('some/foo');

docRefV9Deprecation(
// @ts-expect-error Combines modular and namespace API
() => onSnapshot(docRef, () => {}),
() => docRef.onSnapshot(() => {}),
'onSnapshot',
Expand All @@ -1189,6 +1207,7 @@ describe('Firestore', function () {
const docRef = firestore.doc('some/foo');

docRefV9Deprecation(
// @ts-expect-error Combines modular and namespace API
() => setDoc(docRef, { foo: 'bar' }),
() => docRef.set({ foo: 'bar' }),
'set',
Expand All @@ -1201,6 +1220,7 @@ describe('Firestore', function () {
const docRef = firestore.doc('some/foo');

docRefV9Deprecation(
// @ts-expect-error Combines modular and namespace API
() => updateDoc(docRef, { foo: 'bar' }),
() => docRef.update({ foo: 'bar' }),
'update',
Expand Down
Loading
Loading