5

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)
4
  • 1
    can you try breakpoint after store is created. probably at rrfProps object declaration part and see if store is undefined? Commented Aug 22, 2020 at 6:00
  • tried debugging before and after store is created no new errors just this one listed above. Commented Aug 23, 2020 at 3:29
  • 3
    is <App/> should be inside ReactReduxFirebaseProvider ?and another thing, you can write store?.dispatch using optional chaining to avoid throwing the TypeError. Commented Aug 23, 2020 at 14:42
  • i just fixed it and all wrking fine by putting ``` <App/>``` inside ReactReduxProvider Commented Aug 23, 2020 at 17:41

1 Answer 1

3

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.