这是我第一次使用firebase,我想知道如何将const firebaseApp
传递到<Provider / <Router/>
组件,或者最好的方法是什么?我正在尝试将其传递到主页组件之后的 MainPage 组件。干杯!
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import * as firebase from 'firebase';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
import Router from './Router';
class App extends Component {
componentWillMount() {
const config = {
apiKey: 'xxx',
authDomain: 'xxx',
databaseURL: 'xxx',
storageBucket: 'xxx',
messagingSenderId: 'xxx'
};
// firebase.initializeApp(config);
const firebaseApp = firebase.initializeApp(config);
}
render() {
const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));
return (
<Provider store={store}>
<Router initializeApp={this.initApp} />
</Provider>
);
}
}
export default App;