Skip to content

Instantly share code, notes, and snippets.

@danielbischoff
Last active June 14, 2018 23:16
Show Gist options
  • Save danielbischoff/0729bb74799ff4634ab67740c55e188f to your computer and use it in GitHub Desktop.
Save danielbischoff/0729bb74799ff4634ab67740c55e188f to your computer and use it in GitHub Desktop.
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