scrimba
Frontend Career Path
React basics
Meme generator
Boxes challenge part 4
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

AboutCommentsNotes
Boxes challenge part 4
Expand for more info
App.js
run
preview
console
import React from "react"
import boxes from "./boxes"
import Box from "./Box"

export default function App() {
const [squares, setSquares] = React.useState(boxes)

function toggle(id) {
/**
* Challenge: use setSquares to update the
* correct square in the array.
*
* Make sure not to directly modify state!
*
* Hint: look back at the lesson on updating arrays
* in state if you need a reminder on how to do this
*/
}

const squareElements = squares.map(square => (
<Box
key={square.id}
id={square.id}
on={square.on}
toggle={toggle}
/>
))

return (
<main>
{squareElements}
</main>
)
}
Console
1
,
2
,
3
,
4
,
5
,
6
,
/index.html
"> "> "> "> ">
-5:50