scrimba
React Bootcamp Course
Intro to React Router
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

Intro to React Router
AboutCommentsNotes
Intro to React Router
Expand for more info
App.js
run
preview
console
import React, {useState} from "react"

function App() {
const [page, setPage] = useState("home")

function swapPages(newPage) {
setPage(prevPage => newPage)
}

return (
<div>
<nav>
<button onClick={() => swapPages("home")}>Home</button>
<button onClick={() => swapPages("about")}>About</button>
</nav>
{
page === "home" ?
<h1>Home Page</h1> :
<h1>About page</h1>
}
</div>
)
}

export default App
Console
/index.html
-6:35