Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(firestoreConnect): Warning: Failed prop type when using connect(..., mapDispatchToProps) #611

Closed
rscotten opened this issue Jan 8, 2019 · 3 comments

Comments

@rscotten
Copy link
Contributor

rscotten commented Jan 8, 2019

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).

@prescottprue
Copy link
Owner

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.

@rscotten
Copy link
Contributor Author

rscotten commented Jan 8, 2019

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

@rscotten rscotten closed this as completed Jan 8, 2019
prescottprue added a commit that referenced this issue Jan 8, 2019
* feat(auth): exposing handleRedirectResult for react-firebaseui - #608 - @dirathea
* fix(firestoreConnect): fix invalid proptypes - #611 & [redux-firestore 165](prescottprue/redux-firestore#165)
@prescottprue
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants