Skip to content

Instantly share code, notes, and snippets.

@Ledoux
Last active April 8, 2019 23:07
Show Gist options
  • Save Ledoux/85d408562fa2a41d70ac131b5db3a31a to your computer and use it in GitHub Desktop.
Save Ledoux/85d408562fa2a41d70ac131b5db3a31a to your computer and use it in GitHub Desktop.
const selectStocksByOfferId = createSelector(
state => state.data.stocks,
state, offerId => offerId,
(stocks, offerId) => stocks && stocks.filter(stock => stock.offerId === offerId)
)
function mapStateToProps(state, ownProps) {
const { match: { params: { offerId } } } = ownProps
return {
offer: selectOfferById(state, offerId),
stocks: selectStocksByOfferId(state, offerId)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment