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

React Router useHistory
AboutCommentsNotes
React Router useHistory
Expand for more info
pages
services
ServiceDetail.js
run
preview
console
import React from "react"
import {useParams} from "react-router-dom"

import servicesData from "./servicesData"

function ServiceDetail() {
const {serviceId} = useParams()
const thisService = servicesData.find(service => service._id === serviceId)

return (
<div>
<h1>Service Detail Page</h1>
<h3>{thisService.name} - ${thisService.price}</h3>
<p>{thisService.description}</p>
</div>
)
}

export default ServiceDetail
Console
/services
-5:07