React-redux-firebase: bug(firestoreConnect): Warning: Failed prop type when using connect(..., mapDispatchToProps)

Created on 8 Jan 2019  路  3Comments  路  Source: prescottprue/react-redux-firebase

The following console warning appears when calling firestoreConnect() with react-redux's connect(..., mapDispatchToProps), but everything still works as expected.

Warning: Failed prop type: The prop `dispatch` is marked as required in `FirestoreConnect(RenderContainer)`, but its value is `undefined`.
    in FirestoreConnect(RenderContainer) (created by Connect(FirestoreConnect(RenderContainer)))
    in Connect(FirestoreConnect(RenderContainer)) (created by LoadableComponent)

Seems like a rogue propType issue.

The code is here:

import { RenderContainer } from './RenderContainer';
import { connect } from 'react-redux';
import { compose } from 'recompose';
import { RootState } from '@types';
import { firestoreConnect } from 'react-redux-firebase';
import { Dispatch, bindActionCreators } from 'redux';

interface OwnProps {}
interface DispatchProps {}
type Props = OwnProps & DispatchProps;

const mapDispatchToProps = (dispatch: Dispatch<RootState>): DispatchProps =>
  bindActionCreators(
    {
      // action creators go here
    },
    dispatch
  );

export default compose<Props, OwnProps>(
  connect(
    null,
    mapDispatchToProps
  ),
  firestoreConnect(['items/{itemId}']) 
)(RenderContainer);

Interestingly, there's no warning if and only if firestoreConnect is called before connect AND mapDispatchToProps is null. But the warning appears if firestoreConnect is called after connect with and without mapDispatchToProps.

I'm on the 3.0.0-alpha.5 branch using Chrome 71.0.3578.98 (latest).

All 3 comments

It is totally a rouge propType issue. This was also reported in the redux-firestore repo, so there is already a change in for PR to fix the issue.

Just tried out the v3.0.0-alpha.6 and confirmed no more warning. Thanks and great work!

@rscotten Glad to know. Just released it to the next tag.

Was this page helpful?
0 / 5 - 0 ratings