Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hemepositive/bad5be3f1aecdbf41de0cc9233f03a60 to your computer and use it in GitHub Desktop.
Save hemepositive/bad5be3f1aecdbf41de0cc9233f03a60 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