“TypeError: Object(…) is not a function” react-redux-firebase

前端 未结 4 1337
借酒劲吻你
借酒劲吻你 2020-12-16 21:01

I\'m trying to create a project in React and I\'m using Firebase. In my react-redux-firebase project one line of code making error but I couldn\'t fix that. How could I fix

4条回答
  •  一生所求
    2020-12-16 21:23

    The reactReduxFirebase store enhancer is removed in the version v3 and above. You can now create firebase instance using context providers. The same can now be done as:

    const store = createStore(
      rootReducer,
      compose(
       applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
       reduxFirestore(fbConfig)
     )
    );
    
    const rrfProps = {
    firebase,
    config: fbConfig,
    dispatch: store.dispatch
    }
    
    const App = () => (
      
        
                // your Component
        
      
     );
    

    As of now the 'reduxFirestore' is working fine so I want to leave it as it is but I assume the same will happen to it in coming days. So its a good idea to omit compose and reduxFirestore(fbConfig) and instead use:

    import { createFirestoreInstance } from 'redux-firestore'
    

    and add createFirestoreInstance to rrfProps as below:

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

    For more information checkout: http://react-redux-firebase.com/docs/v3-migration-guide.html#remove-createFirebaseConnect-and-createFirestoreConnect

提交回复
热议问题