【发布时间】:2019-01-17 01:19:10
【问题描述】:
我正在使用 firebase auth 包为我的 ReactJS 应用程序创建一个登录页面。
我已经在我的全局 firebase 文件中导入了 auth 包:
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 命名空间吧??
【问题讨论】:
标签: typescript firebase firebase-authentication es6-modules