scrimba
Frontend Career Path
React basics
Meme generator
useEffect() syntax and default behavior
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() syntax and default behavior
AboutCommentsNotes
useEffect() syntax and default behavior
Expand for more info
App.js
run
preview
console
import React from "react"

export default function App() {
const [starWarsData, setStarWarsData] = React.useState({})

// console.log("Component rendered")

// fetch("https://swapi.dev/api/people/1")
// .then(res => res.json())
// .then(data => setStarWarsData(data))

// side effects

return (
<div>
<pre>{JSON.stringify(starWarsData, null, 2)}</pre>
</div>
)
}
Console
/index.html
-2:59