Good day, I’m having problems with the latest react-router-dom v6, I still learning the new version. Please help.
import React from 'react'
function Bookingscrren({match}) {
return (
<div>
<h1>Booking Page</h1>
<h1>Room id = {match.useParams.roomid}</h1>
</div>
)
}
export default Bookingscrren
Please be kind 🙂 I’m new
>Solution :
That’s not the right way of using useParams. All of these functions that begin with use, or react hooks, are just those, functions. That means you call them to get access to their functionality.
import React from 'react'
function Bookingscrren() {
const params = useParams();
return (
<div>
<h1>Booking Page</h1>
<h1>Room id = {params.roomid}</h1>
</div>
)
}
The return value of useParams is an object with parameters. You can access each one with the . operator.
