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

426
Views
React useParams undefined

I am doing a personal React.js project. I am having issues with useParams. One of the issues that I am facing is that I cannot find a common id for the useParams. I am not able to show on screen the items that I pass as props in ItemDetails. This is the ItemContainer.:

import { useEffect, useState } from "react";

import ItemDetails from "../Itemdetails";
import { useParams } from "react-router-dom";

const showRace = async (raceId) => {
  const res = await fetch("https://www.betright.com.au/api/racing/todaysracing");
  const json = await res.json().result;
  const race = Object.keys(json).find((findKey) => findKey === String(raceId));

  if (!race) {
    throw new Error("No match found.");
  }
  console.log('race in showRace', race)

  return race;
}

const ItemContainer = () => {
  const [venue, setVenue] = useState({});
  const { raceId } = useParams();

  useEffect(() => {
    showRace(raceId)
      .then((races) => {
        setVenue(races)
      })
      .catch(error => {
        console.error('error useEffect itemContainer', error)
        setVenue({});
      })
  }, [raceId]);
  console.log("venue container", venue);

  return <ItemDetails key={raceId} venue={venue} />;
};

export default ItemContainer;

This is the ItemDetails:

const ItemDetails = ({ venue }) => {
  console.log("venue itemDetails", venue);
  return (
    <>
      {Object.entries(venue).map(([key, value]) => (
        <div key={key}>
          <h1>{key}</h1>
          {value.slice(0, 5).map((i, races) => (
            <div key={i}>
              <p>{races.Venue}</p>
            </div>
          ))}
        </div>
      ))}
    </>
  );
};

export default ItemDetails;

This is a link to a codesandbox with the whole code.

about 4 years ago · Juan Pablo Isaza
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!