Skip to content

Instantly share code, notes, and snippets.

@jmlavoier
Created September 29, 2017 01:42
Show Gist options
  • Save jmlavoier/8c332e136744c5d90ed0740540d8b7ac to your computer and use it in GitHub Desktop.
Save jmlavoier/8c332e136744c5d90ed0740540d8b7ac to your computer and use it in GitHub Desktop.
class App extends React.Component {
constructor() {
super();
this.state = {
active: true,
}
}
onClick(event) {
const { active } = this.state;
this.setState({
active: !active,
});
this.input.focus(); //focus <--
}
render() {
const { active } = this.state;
return (
<div>
<Button
description={active ? 'Ativado' : 'Desativado'}
onClick={this.onClick.bind(this)}
/>
<input ref={input => this.input = input} />
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment