Warning: It looks like you're using the development build of the Firebase JS SDK

前端 未结 3 1954
无人及你
无人及你 2020-11-30 04:53

I\'ve integrated Firebase into my React.js app as such: https://firebase.google.com/docs/database/web/start

fire.js:
import firebase from \'firebase\'

var          


        
相关标签:
3条回答
  • 2020-11-30 04:59

    The warning is rather informative and lays out exactly what you need to do. In your case, this is the line thats telling you to switch up the way you are importing your files:

    ES Modules: import firebase from 'firebase/app'; import 'firebase/';

    In your fire.js file try changing this:

    import firebase from 'firebase'
    

    To this:

    import firebase from 'firebase/app'
    

    That should clear it up!

    Side note:

    In my case I was using firestore so I had an additional import that I also changed from:

    import firestore from 'firebase/firestore'
    

    To:

    import 'firebase/firestore'
    
    0 讨论(0)
  • 2020-11-30 05:06

    The proper way to import firebase is as such:

    import firebase from 'firebase/app';
    import 'firebase/database'; // If using Firebase database
    import 'firebase/storage';  // If using Firebase storage
    
    0 讨论(0)
  • 2020-11-30 05:08

    The proper way to import firebase and getting rid of the warnings is:

    Always import this way

    import firebase from 'firebase/app';
    

    Then import each sub-modules (each firebase service) as needed

    import 'firebase/auth';        // for authentication
    import 'firebase/storage';     // for storage
    import 'firebase/database';    // for realtime database
    import 'firebase/firestore';   // for cloud firestore
    import 'firebase/messaging';   // for cloud messaging
    import 'firebase/functions';   // for cloud functions
    
    0 讨论(0)
提交回复
热议问题