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

前端 未结 4 1336
借酒劲吻你
借酒劲吻你 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:13

    Please use this npm packages
    npm packages compatibility issue

    npm i --save react-redux@5.1.1 react-redux-firebase@2.2.4
    
    0 讨论(0)
  • 2020-12-16 21:13

    Option 01- adjust npm package versions for react-redux & react-redux-firebase

    npm install react-redux@5.1.1 react-redux-firebase@2.2.4
    

    Option 02- Refer v3 ( http://react-redux-firebase.com/docs/v3-migration-guide.html )

    0 讨论(0)
  • 2020-12-16 21:17

    This is a react-redux-firebase v2.x.x coding pattern and you probably have v3.x.x installed.

    1. Check which version of react-redux-firebase you are using:
        npm ls react-redux-firebase
    
    1. If the version is 3.0.0 or higher, you need to migrate your code to the new coding pattern. See React-Redux-Firebase v3.x.x Migration Guide for detailed instructions.
    0 讨论(0)
  • 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 = () => (
      <Provider store={store}>
        <ReactReduxFirebaseProvider {...rrfProps}>
          <Todo />      // your Component
        </ReactReduxFirebaseProvider>
      </Provider>
     );
    

    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

    0 讨论(0)
提交回复
热议问题