Last active
August 30, 2016 08:51
-
-
Save mmollaverdi/a62a8d25e7747879be7aae7ce50d44a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import stateTransformers from './searchFormStateTransformers'; | |
import SearchForm from './SearchForm'; | |
module.exports = class SearchFormContainer extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = // initial state | |
this.stateUpdaters = { | |
updateFilters: (filterName, filterValue) => | |
this.setState(stateTransformers.updateFilters(this.state)(filterName, filterValue)), | |
clearFilters: () => | |
this.setState(stateTransformers.clearFilters(this.state)), | |
switchTab: () => | |
this.setState(stateTransformers.switchTab(this.state)), | |
routeFilters: mostRecentSearch => | |
this.setState(stateTransformers.routeFilters(this.state)(mostRecentSearch)), | |
selectSearchHistory: selectedSearchFromHistory => | |
this.setState(stateTransformers.selectSearchHistory(this.state)(selectedSearchFromHistory)) | |
} | |
} | |
render() { | |
return <SearchForm {...this.state} {...this.stateUpdaters} />; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment