4

Hi i get this error when in my browser when i run my code:

TypeError: Object(...) is not a function ./src/index.js src/index.js:31

28 | firebaseStateName: 'firebase' 29 | } 30 | const initialState = {};

31 | const store = createStore(rootReducer,initialState, 32 | compose( 33 | applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })), 34 | reactReduxFirebase(firebase, config),

i tryed using thing libary:

http://docs.react-redux-firebase.com/history/v3.0.0/docs/integrations/thunks.html

however still no succes :/

below my index.js file

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, reduxFirestore, getFirestore } from 'redux-firestore';
import { ReactReduxFirebaseProvider, reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import fbConfig from './config/fbconfig'
import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
import 'firebase/storage'
import 'firebase/functions'

firebase.initializeApp(fbConfig);
firebase.firestore();
firebase.storage().ref();
firebase.functions();
const config = {
    useFirestoreForProfile:true,
    userProfile: 'Klanten',
    userFirestoreForProfile: true,
    attachAuthIsReady: true,
    firebaseStateName: 'firebase'
}
const initialState = {};
const store = createStore(rootReducer,initialState,
    compose(
        applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
        reactReduxFirebase(firebase, config),
        reduxFirestore(firebase)
    )
)

store.firebaseAuthIsReady.then(() => {
    const rrfProps = {
        firebase,
        config: fbConfig,
        dispatch: store.dispatch,
        createFirestoreInstance
    }

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

this is my rootReducer.js

import authReducer from './authReducer'
import shopReducer from './shopReducer'
import { combineReducers } from 'redux'
import { firebaseReducer } from 'react-redux-firebase'
import { firestoreReducer } from 'redux-firestore'

const rootReducer = combineReducers({
    firebase: firebaseReducer,
    firestore: firestoreReducer,
    auth: authReducer,
    shop: shopReducer
})

export default rootReducer

1 Answer 1

10

This is where your problem is:

    reactReduxFirebase(firebase, config),
    reduxFirestore(firebase)

There has been a little change in the configuration in the latest version, which you must use if you're using react V6.

*Make sure you install the latest version by typing:

npm i --save react-redux-firebase@next

http://docs.react-redux-firebase.com/history/v3.0.0/docs/v3-migration-guide.html

+ import { ReactReduxFirebaseProvider } from 'react-redux-firebase'
+ import { createFirestoreInstance } from 'redux-firestore'
- import { reactReduxFirebase } from 'react-redux-firebase' // removed
- import { reduxFirestore } from 'redux-firestore'          // removed

const store = createStore(
  rootReducer,
  initialState,
  compose(
-    reactReduxFirebase(firebase, rrfConfig), // removed
-    reduxFirestore(firebase)
    //  applyMiddleware(...middleware)       // removed
  )
)

+ const rrfProps = {
+   firebase,
+   config: rrfConfig,
+   dispatch: store.dispatch,
+   createFirestoreInstance // <- needed if using firestore
+ }
const App = () => (
  <Provider store={store}>
+   <ReactReduxFirebaseProvider {...rrfProps}>
      <Todos />
+   </ReactReduxFirebaseProvider>
  </Provider>
);
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.