Skip to content

Commit

Permalink
fix(HOCs): missing props (firebase + dispatch) added - #606
Browse files Browse the repository at this point in the history
  • Loading branch information
prescottprue committed Jan 16, 2019
1 parent d322124 commit 4c9c0c0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/withFirestore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import hoistStatics from 'hoist-non-react-statics'
import { wrapDisplayName } from './utils'
import ReactReduxFirebaseContext from './ReactReduxFirebaseContext'
import ReduxFirestoreContext from './ReduxFirestoreContext'

/**
Expand Down Expand Up @@ -35,9 +36,20 @@ export const createWithFirestore = (storeKey = 'store') => WrappedComponent => {
const HoistedComp = hoistStatics(WithFirestore, WrappedComponent)

const withFirestore = props => (
<ReduxFirestoreContext.Consumer>
{firestore => <HoistedComp firestore={firestore} {...props} />}
</ReduxFirestoreContext.Consumer>
<ReactReduxFirebaseContext.Consumer>
{firebase => (
<ReduxFirestoreContext.Consumer>
{firestore => (
<HoistedComp
firestore={firestore}
firebase={firebase}
dispatch={firebase.dispatch}
{...props}
/>
)}
</ReduxFirestoreContext.Consumer>
)}
</ReactReduxFirebaseContext.Consumer>
)

withFirestore.displayName = wrapDisplayName(WrappedComponent, 'withFirestore')
Expand Down

0 comments on commit 4c9c0c0

Please sign in to comment.