亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么它返回空值?

為什么它返回空值?

揚帆大魚 2023-05-25 17:18:13
嗨,我正在嘗試學習 firebase?,F在我正在嘗試關注 github 文檔中的內容。?這是我的 index.js 文件const rfConfig = {}; // optional redux-firestore Config Options// Your web app's Firebase configurationconst firebaseConfig = {? apiKey: 'something',? authDomain: 'something',? databaseURL: 'something',? projectId: 'something',? storageBucket: 'something.com',? messagingSenderId: 'something',? appId: '1:something',? measurementId: 'G-something',};firebase.initializeApp(firebaseConfig);// Initialize Cloud Firestore through Firebasefirebase.firestore();// Add reduxFirestore store enhancer to store creatorconst createStoreWithFirebase = compose(? reduxFirestore(firebase, rfConfig), // firebase instance as first argument, rfConfig as optional second)(createStore);// Add Firebase to reducersconst rootReducer = combineReducers({? firestore: firestoreReducer,});// Create store with reducers and initial stateconst initialState = {};const store = createStoreWithFirebase(rootReducer, initialState);ReactDOM.render(? <React.StrictMode>? ? <Provider store={store}>? ? <App />? ? </Provider>? </React.StrictMode>,? document.getElementById('root'));我的文件夾有 3 個組件。1 用于添加待辦事項。1 用于顯示待辦事項。& 最后一個是前兩個的組合
查看完整描述

1 回答

?
largeQ

TA貢獻2039條經驗 獲得超8個贊

您需要ReactReduxFirebaseProvider在組件樹的頂部附近渲染一個。這就是useFirebase試圖訪問的內容,因此如果沒有,您將無法定義。


const rrfConfig = {

? userProfile: 'users'

? // useFirestoreForProfile: true // Firestore for Profile instead of Realtime DB

}


const rrfProps = {

? firebase,

? config: rrfConfig,

? dispatch: store.dispatch

? // createFirestoreInstance // <- needed if using firestore

}


ReactDOM.render(

? <React.StrictMode>

? ? <Provider store={store}>

? ? ? <ReactReduxFirebaseProvider {...rrfProps}>

? ? ? ? <App />

? ? ? </ReactReduxFirebaseProvider>

? ? </Provider>

? </React.StrictMode>,

? document.getElementById('root')

);

查看完整回答
反對 回復 2023-05-25
  • 1 回答
  • 0 關注
  • 137 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號