警告:您似乎在使用 Firebase JS SDK 的开发版本 [英] Warning: It looks like you're using the development build of the Firebase JS SDK
问题描述
我已将 Firebase 集成到我的 React.js 应用程序中,如下所示:
导入 firebase 的正确方法如下:
从'firebase/app'导入firebase;导入火力库/数据库";//如果使用 Firebase 数据库导入火力基地/存储";//如果使用 Firebase 存储
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 config = {
apiKey: "####",
authDomain: "#",
databaseURL: "#",
projectId: "#",
storageBucket: "#",
messagingSenderId: "#"
};
var fire = firebase.initializeApp(config);
export default fire;
App.js:
import fire from './fire';
class App extends Component {
componentWillMount(){
let messagesRef = fire.database().ref('messages').orderByKey().limitToLast(100);
}
}
But now I'm getting this warning in the console:
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 with the name of a component - i.e. auth, database, etc):
CommonJS Modules: const firebase = require('firebase/app'); require('firebase/');
ES Modules: import firebase from 'firebase/app'; import 'firebase/';
How do I fix this warning?
I have tried (in fire.js) changing this:
import firebase from 'firebase'
To this:
import firebase from 'firebase/app'
That results in this error:
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
这篇关于警告:您似乎在使用 Firebase JS SDK 的开发版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!