Course Content
Introduction to React
Introduction to React
Using Params
We can access passed parameters in the URL using the useParams
hook. Here is an example.
You can specify parameters in URLs using the colon operator followed by the name of the parameter :param
.
The parameter can be accessed inside the target component using the useParam
hook. Notice how we enclose the bookid
term inside braces { bookid }
- it is because useParam
returns an object and we retrieve the bookid
by unpacking the object using this syntax.
![carousel-img](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/118c2a49-583d-43eb-a9df-07bc65025c91/s.6+ch.4+pict1.png?w=3840&q=75)
![carousel-img](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/118c2a49-583d-43eb-a9df-07bc65025c91/s.6+ch.4+pict2.png?w=3840&q=75)
Everything was clear?