我正在尝试在我的 react native 项目中初始化 firebase。
This is the error I am facingApp.js
的代码我在哪里初始化它
import React, {Component} from 'react';
import {View, Text} from 'react-native';
import {Provider} from 'react-redux';
import {createStore} from 'redux';
import reducers from './reducers';
import firebase from 'firebase';
class App extends Component {
componentWillMount () {
const config = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: ""
};
firebase.initializeApp(config);
}
render() {
return (
<Provider store={createStore(reducers)}>
<View>
<Text>Hello! </Text>
</View>
</Provider>
);
}
}
export default App;
当我只包含
import firebase from 'firebase';
时,我什至面临同样的错误并且不要初始化 config
最佳答案
导出在 5.0.4 及更高版本中发生了变化。现在你需要这样做:import firebase from '@firebase/app'
如果你正在使用 eslint,你可能会提示它应该列在项目依赖项中,但你可以忽略它。
您可能还想使用 firebase 的实际功能,而不仅仅是核心导入。例如,要使用身份验证模块,您需要添加以下内容:import '@firebase/auth'
关于reactjs - 对象作为 react 子无效(react-native),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50730706/