Only map the required props/funcs to the show list view

This commit is contained in:
Grégoire Delattre 2017-05-23 21:16:10 +02:00
parent 3a93433703
commit 1d1e239709

View File

@ -1,7 +1,8 @@
import React from 'react' import React from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { bindActionCreators } from 'redux' import { bindActionCreators } from 'redux'
import * as actionCreators from '../../actions/actionCreators' import { selectShow, addShowToWishlist,
deleteFromWishlist, getShowDetails } from '../../actions/actionCreators'
import ListDetails from '../list/details' import ListDetails from '../list/details'
import ListPosters from '../list/posters' import ListPosters from '../list/posters'
@ -11,15 +12,10 @@ function mapStateToProps(state) {
return { showStore: state.showStore }; return { showStore: state.showStore };
} }
const mapDispatchToProps = (dispatch) => const mapDispatchToProps = (dispatch) =>
bindActionCreators(actionCreators, dispatch) bindActionCreators({ selectShow, addShowToWishlist,
deleteFromWishlist, getShowDetails }, dispatch)
class ShowList extends React.Component { class ShowList extends React.Component {
componentWillMount() {
if (this.props.showsUrl) {
this.props.fetchShows(this.props.showsUrl);
return
}
}
render() { render() {
const shows = this.props.showStore.shows; const shows = this.props.showStore.shows;
const selectedShowId = this.props.showStore.selectedImdbId; const selectedShowId = this.props.showStore.selectedImdbId;
@ -37,9 +33,7 @@ class ShowList extends React.Component {
formModel="showStore" formModel="showStore"
filterControlModel="showStore.filter" filterControlModel="showStore.filter"
filterControlPlaceHolder="Filter shows..." filterControlPlaceHolder="Filter shows..."
fetchExploreOptions={this.props.getShowExploreOptions}
exploreOptions={this.props.showStore.exploreOptions} exploreOptions={this.props.showStore.exploreOptions}
explore={this.props.exploreShows}
selectedImdbId={selectedShowId} selectedImdbId={selectedShowId}
filter={this.props.showStore.filter} filter={this.props.showStore.filter}
perPage={this.props.showStore.perPage} perPage={this.props.showStore.perPage}