gpt4 book ai didi

javascript - 类型错误 : Cannot read property 'dispatch' of null

转载 作者:行者123 更新时间:2023-12-03 23:44:44 26 4
gpt4 key购买 nike

在尝试将我的 firestore 连接到 reducer 后,我刚刚收到此错误,因为我注意到 cnt 从我的 firestore 获取任何数据,所以问题出在 index.js 文件,因为它发生在我在 v2 到 v3 之间进行迁移之后,并且当错误开始时,如果你能帮我找出问题,请

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import {createStore, applyMiddleware, compose } from 'redux'
import rootreducer from './store/reducers/rootreducer'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import { createFirestoreInstance, getFirestore, reduxFirestore } from 'redux-firestore'
import { ReactReduxFirebaseProvider, getFirebase} from 'react-redux-firebase'
import fbconfig from './config/fbconfig'
import firebase from 'firebase/app'
const store = createStore(
rootreducer,
compose(
applyMiddleware(thunk.withExtraArgument({ getFirestore, getFirebase })),
reduxFirestore(firebase, fbconfig)
)
);

const rrfProps = {
firebase,
config: fbconfig,
dispatch: store.dispatch,
createFirestoreInstance
};

ReactDOM.render(
<React.StrictMode>
<Provider store={store}><App />
<ReactReduxFirebaseProvider{...rrfProps}>
</ReactReduxFirebaseProvider>
</Provider>
</React.StrictMode>,
document.getElementById('root')
);

serviceWorker.unregister();

这是我的 仪表板.js 导出时添加撰写时发生错误
export default compose(
connect(mapStateToProps),
firestoreConnect([
{collection: 'projects'}
])
)(Dashboard)

最佳答案

我刚刚在 的帮助下修复了它Kevin Moe Myint Myat 通过把 <App/>里面ReactReduxFirebaseProvider如下所示

ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<ReactReduxFirebaseProvider{...rrfProps}>
<App />
</ReactReduxFirebaseProvider>
</Provider>
</React.StrictMode>,
document.getElementById('root')
);

serviceWorker.unregister();

关于javascript - 类型错误 : Cannot read property 'dispatch' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63533028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com