Skip to content

Instantly share code, notes, and snippets.

@isacjunior
Last active March 29, 2019 19:49
Show Gist options
  • Save isacjunior/03489360e04703cfa2f3d463503edc9e to your computer and use it in GitHub Desktop.
Save isacjunior/03489360e04703cfa2f3d463503edc9e to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
interface State {
name: string
}
class DidUpdate extends Component<{}, State> {
state = {
name: ''
}
componentDidMount() {
console.log('Eu estou montado')
}
componentDidUpdate() {
console.log('Sofri alteração')
}
handleChange = (e: React.ChangeEvent<HTMLInputElement>) =>
this.setState({ name: e.target.value })
render() {
const { name } = this.state
return (
<>
<input value={name} onChange={this.handleChange} />
</>
)
}
}
export default DidUpdate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment