簡體   English   中英

如何避免Firebase警告我正在使用開發版本?

[英]How to avoid Firebase warning that I’m using the development build?

我正在使用firebase auth包為我的ReactJS應用創建登錄頁面。

我已經將auth包導入了我的全局firebase文件中:

import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';

const config = {
    apiKey: "xxx",
    authDomain: "xxx",
    databaseURL: "xxx",
    projectId: "xxx",
    storageBucket: "xxx",
    messagingSenderId: "xxx"
};

export default firebase.initializeApp(config);

現在在我的LoginComponent我需要訪問類FacebookAuthProvider這是一部分firebase.auth命名空間。 為了獲得對該類的訪問權限,我導入auth名稱空間。

import React, { Component } from 'react';
import { auth } from 'firebase';

class Login extends Component {
    provider = new auth.FacebookAuthProvider();

由於最后一次導入,我在控制台中收到以下警告:

It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.

For the module builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):

CommonJS Modules:
const firebase = require('firebase/app');
require('firebase/<PACKAGE>');

ES Modules:
import firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

經過大量的文檔和代碼后,我仍然無法弄清如何在訪問FacebookAuthProvider類時擺脫此警告。

第二個問題:目前我是否正在使用完整的firebase開發SDK? 我只導入了auth名稱空間,對嗎?

您的登錄組件將導入完整的Firebase SDK,這將導致該警告。 您將只需要導入所需的零件。 如果已經加載了相同的文件,則捆綁程序或瀏覽器將重復數據刪除。

更改此:

import React, { Component } from 'react';
import { auth } from 'firebase';

對此:

import React, { Component } from 'react';
import firebase from 'firebase/app';
import 'firebase/auth';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM