Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Is using parts of the URL instead of props for generated class component pages (e.g. specific product page) a good React practice?

I'm new to React, and I'm writing a web store front-end using react router dom to generate pages for the specific product. I split the url for the product page to get product ID and pass that ID as a prop to product class components (like product images, price, qunaitiy, description...), the components then make separate apollo queries for the information they need to properly render. The routes part of the code looks like this:

<Routes>
    <Route path="/" element={<App />} />
    <Route exact path="/:productCategory" element={<CategoryComponent />} />
    <Route exact path="/:productCategory/:productID" element={<ProductPageComponent />} />
</Routes>

I have some doubts about using javascript to split the url and get the product ID from it - it works fine, but somehow feels hacky - is there a better way? I cannot use useParams or any hooks at all - I must use class components for this.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is a good practice because those components are dynamic when receiving params.

read more

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!