Forked from danielbischoff/stores_represent_ui_state.jsx
Created
June 14, 2018 23:16
-
-
Save hemepositive/bad5be3f1aecdbf41de0cc9233f03a60 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
class SearchStore { | |
@observable searchText; | |
@action | |
setSearchText = (searchText) => { | |
this.searchText = searchText | |
} | |
} | |
@observer | |
class SearchInput extends React.Component { | |
handleInputChanged = (event) => { | |
const { searchStore } = this.props; | |
searchStore.setSearchText(event.target.value); | |
} | |
render() { | |
const { searchStore } = this.props; | |
return ( | |
<input | |
value={searchStore.searchText} | |
onChange={this.handleInputChanged} | |
/> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment