Skip to content
This repository was archived by the owner on Sep 28, 2026. It is now read-only.
This repository was archived by the owner on Sep 28, 2026. It is now read-only.

Is it possible to inject react native firebase ataptor? #45

Description

@pie6k

I've tried to check adaptor module, but it seems adaptors for browser and node are hardcoded there. Even if I can inject adaptor into node adaptor, the one from google is still imported there so I'd have to have it installed in my react native project.

React Native Firebase is trying to have the same JS API as browser one

import firestore from '@react-native-firebase/firestore';

// Get user document with an ID of ABC
const userDocument = firestore()
  .collection('Users')
  .doc('ABC');

https://rnfirebase.io/firestore/usage

Activity

  1. kossnocorp commented on Apr 22, 2020

    @kossnocorp
    Owner

    Hey! That's an interesting problem. I never considered React Native but now it makes sense. It looks like React Native supports the react-native field in package.json so I can add a special adaptor for it.

  2. kossnocorp commented on Apr 22, 2020

    @kossnocorp
    Owner

    @pie6k I've added experimental React Native adaptor #46 but can't build it as TypeScript detects a dozen of type errors in the @react-native-firebase/firestore type definitions. I'm wondering if you use it with TypeScript and if so, do you have such issues:

    Show errors

    node_modules/@react-native-firebase/app/lib/index.d.ts:395:3 - error TS2666: Exports and export assignments are not permitted in module augmentations.
    
    395   export default module;
          ~~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:124:32 - error TS2304: Cannot find name 'value'.
    
    124     add(data: { [key: string]: value }): Promise<DocumentReference>;
                                       ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:425:32 - error TS2304: Cannot find name 'value'.
    
    425     set(data: { [key: string]: value }, options?: SetOptions): Promise<void>;
                                       ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:444:35 - error TS2304: Cannot find name 'value'.
    
    444     update(data: { [key: string]: value }): Promise<void>;
                                          ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:505:30 - error TS2304: Cannot find name 'value'.
    
    505     data(): { [key: string]: value } | undefined;
                                     ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:566:30 - error TS2304: Cannot find name 'value'.
    
    566     data(): { [key: string]: value };
                                     ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1573:30 - error TS2304: Cannot find name 'value'.
    
    1573       data: { [key: string]: value },
                                      ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1598:67 - error TS2304: Cannot find name 'value'.
    
    1598     update(documentRef: DocumentReference, data: { [key: string]: value }): Transaction;
                                                                           ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1699:30 - error TS2304: Cannot find name 'value'.
    
    1699       data: { [key: string]: value },
                                      ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1720:67 - error TS2304: Cannot find name 'value'.
    
    1720     update(documentRef: DocumentReference, data: { [key: string]: value }): WriteBatch;
                                                                           ~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1924:66 - error TS2314: Generic type 'Promise<T>' requires 1 type argument(s).
    
    1924     runTransaction(updateFunction: (transaction: Transaction) => Promise): Promise<any>;
                                                                          ~~~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1947:3 - error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.
    
    1947   import { ReactNativeFirebase } from '@react-native-firebase/app';
           ~~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1948:3 - error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.
    
    1948   import ReactNativeFirebaseModule = ReactNativeFirebase.Module;
           ~~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1949:3 - error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.
    
    1949   import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp;
           ~~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1952:27 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.
    
    1952   export const firebase = firebaseNamedExport;
                                   ~~~~~~~~~~~~~~~~~~~
    
    node_modules/@react-native-firebase/firestore/lib/index.d.ts:1958:3 - error TS2666: Exports and export assignments are not permitted in module augmentations.
    
    1958   export default defaultExport;
           ~~~~~~
    
    
    Found 16 errors.
    

  3. kossnocorp commented on Apr 22, 2020

    @kossnocorp
    Owner

    Ok, I've figured that they have buggy definitions, but I managed to disable those and released typesaurus@6.1.0-alpha.1.

    @pie6k could please test it and see if it works. It supposed to work out-of-the-box without injecting the adaptor.

  4. pie6k commented on Apr 22, 2020

    @pie6k
    Author

    I'll try to play with it a bit later.

    I've also added a few comments to #46 that might simplify it a bit.

  5. kossnocorp commented on May 13, 2024

    @kossnocorp
    Owner

    I'm not sure what the state of React Native and Firebase is, but I can see that people use Firebase Web SDK. If someone needs React Native Firebase package adaptor, please open a new issue with more details about why an adaptor is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions