scrimba
Frontend Career Path
React basics
Meme generator
Boxes challenge part 2
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 2
Expand for more info
App.js
run
preview
console
import React from "react"
import boxes from "./boxes"

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

const squareElements = squares.map(square => (
<div className="box" key={square.id}></div>
))
/**
* Challenge part 2:
* 1. Create a separate component called "Box" and
* replace the `div` above with our <Box /> components
* 2. Pass the Box component a prop called `on` with the
* value of the same name from the `boxes` objects
* 3. In the Box component, apply dynamic styles to determine
* the backgroundColor of the box. If it's `on`, set the
* backgroundColor to "#222222". If off, set it to "none"
*/

return (
<main>
{squareElements}
</main>
)
}
Console
/index.html
-3:37