TypeError: Cannot read property 'dispatch' of null

Viewed 3179

i just got this error after trying to connect my firestore to the reducer and as i noticed that cnt get any data from my firestore so the problem is here in the index.js file because it happened after i was doing the migration between v2 to v3 and that when the error starts so plzz if you can help me find out the problem

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();

this is my dashboard.js export when added compose the error occured

export default compose(
    connect(mapStateToProps),
    firestoreConnect([
        {collection: 'projects'}
    ])
)(Dashboard)
1 Answers

I've just fixed it with the help of Kevin Moe Myint Myat by putting <App/> inside the ReactReduxFirebaseProvider as shown below

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

serviceWorker.unregister();
Related