scrimba
Learn React for free
Lifecycle Methods Part 3 - componentDidUpdate
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Lifecycle Methods Part 3 - componentDidUpdate
AboutCommentsNotes
Lifecycle Methods Part 3 - componentDidUpdate
Expand for more info
App.js
run
preview
console
import React from "react"

class App extends React.Component {
constructor() {
super()
this.state = {
count: 0
}
this.increment = this.increment.bind(this)
}

increment() {
this.setState(prevState => {
return {
count: prevState.count + 1
}
})
}

render() {
return (
<div>
<h1>{this.state.count}</h1>
<button onClick={this.increment}>
Increment!
</button>
</div>
)
}
}

export default App
Console
/index.html
-8:34