scrimba
Learn React for free
useEffect() Part 1
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

useEffect() Part 1
AboutCommentsNotes
useEffect() Part 1
Expand for more info
App.js
run
preview
console
import React, {useState} from "react"

function App() {
const [count, setCount] = useState(0)
const [answer, setAnswer] = useState("Yes")

function increment() {
setCount(prevCount => prevCount + 1)
}

function decrement() {
setCount(prevCount => prevCount - 1)
}

return (
<div>
<h1>{count}</h1>
<button onClick={increment}>Increment</button>
<button onClick={decrement}>Decrement</button>
</div>
)
}

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