question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question: How do I get path parameters?

See original GitHub issue

I have a route that looks like this:

<Route path="/tests/:testname" component="{ViewTest}" />

I want to access the :testname value inside the ViewTest component but it wasn’t obvious to me the best way to do this. Any help would be appreciated?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
gisslehcommented, Jul 16, 2019

I was wondering the same, and found out that if you export let testname in ViewTest, it will set that.

0reactions
EmilTholincommented, Aug 5, 2019

Hi @matryer!

Like @gissleh said you should export the variables from the component of the Route, since the path parameters will be passed to the rendered component.

This is mentioned briefly in the documentation:

Potential route parameters will be passed to the rendered component as properties.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are Path Parameters? Technical topics explained simply
Path parameters are request parameters attached to a URL that point to a specific REST API resource. The path parameter is separated from ......
Read more >
Rest Standard: Path parameters or Request parameters
This is a great fundamental question. I've recently come to the conclusion to stay away from using path parameters ...
Read more >
Path vs Query Parameters in HTTP Requests (with Postman)
Want to learn more about Postman? Get my Postman complete course at a special price and help support this YouTube ...
Read more >
What are Query Parameters (in API terms) - RapidAPI
API Query parameters can be defined as the optional key-value pairs that appear after the question mark in the URL. Basically, they are...
Read more >
Reading Path Parameters in Node.js - GeeksforGeeks
The path parameter is a variable that allows the user to add a parameter in his resource point (API endpoint) whose value can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found