React Redux Firebase无法获取firebase.storage

时间:2019-06-03 01:30:28

标签: reactjs firebase redux firebase-storage react-redux-firebase

我正在使用const fd = new FormData(); fd.append('image',this.selectedFile,this.selectedFile.name); console.log(...fd); 软件包,并试图将文件上传到存储设备。

我正在使用react-redux-firebase HOC并获得withFirebase,但是this.prop.firebasethis.props.firebase.storagethis.props.firebase.storage()

当我致电undefined时,出现以下错误:this.props.firebase.uploadFiles(file)

这是我的Firebase storage is required to upload files

index.js

这里是... import { ReactReduxFirebaseProvider } from 'react-redux-firebase' import { createFirestoreInstance, getFirestore, reduxFirestore } from 'redux-firestore' import firebase from './config/firebaseConfig'; const rrfConfig = { userProfile: 'users', useFirestoreForProfile: true }; const store = createStore(rootReducer, compose( applyMiddleware(thunk.withExtraArgument({ getFirestore })), reduxFirestore(firebase), ) ); const rrfProps = { firebase, config: rrfConfig, dispatch: store.dispatch, createFirestoreInstance }; ReactDOM.render( <Provider store={store}> <ReactReduxFirebaseProvider {...rrfProps}> <App /> </ReactReduxFirebaseProvider> </Provider>, document.getElementById('root') );

./config/firebaseConfig

最后是我的组件:

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

const firebaseConfig = {
    apiKey: "#######",
    authDomain: "#######.firebaseapp.com",
    databaseURL: "https://######.firebaseio.com",
    projectId: "######",
    storageBucket: "########.appspot.com",
    messagingSenderId: "##########",
    appId: "#:#########:web:############"
};
firebase.initializeApp(firebaseConfig);
export default firebase;

1 个答案:

答案 0 :(得分:1)

在您的firebase/storage文件上导入firebase/auth之后添加导入./config/firebaseConfig,然后重试:)