Skip to content

Instantly share code, notes, and snippets.

@joaolucasl
Last active January 11, 2017 20:22
Show Gist options
  • Save joaolucasl/f3c60e593531dbb265cefabbfdc871f1 to your computer and use it in GitHub Desktop.
Save joaolucasl/f3c60e593531dbb265cefabbfdc871f1 to your computer and use it in GitHub Desktop.
Comunicacao de Componentes React
class ParentComponent extends React.Component
{
render() {
return (
<input type="text" ref={(field) => this.editText = field} />
)
}
componentDidMount() {
if (this.editText !== null) {
this.editText.focus()
}
}
}
class ParentComponent extends React.Component
{
render() {
return (
<input type="text" ref="editText"/>
)
}
componentDidMount() {
this.refs.editText.focus()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment