Skip to content

Instantly share code, notes, and snippets.

@yarnball
Created August 17, 2017 11:18
Show Gist options
  • Save yarnball/b1ceb864b397a7834940e2ddb318b317 to your computer and use it in GitHub Desktop.
Save yarnball/b1ceb864b397a7834940e2ddb318b317 to your computer and use it in GitHub Desktop.
import React from 'react';
import Paper from 'material-ui/Paper';
class SearchBar extends React.Component {
state = {
test:false,
};
componentWillMount(){
this.setState({ test: !this.state.test }, () => { this.focus(); });
}
focus = () => {
console.log('this ran!')
this.refs.searcher.focus();
}
render() {
const { onSearchChange, search } = this.props;
return (
<Paper className='searchInput' >
<input onChange={onSearchChange} ref="searcher" placeholder="Search" type="text" />
</Paper>
);
}
}
export default SearchBar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment