Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
React Router Dom Dynamic linking gives wrong data

I'm trying to make a dynamic project page using react router dom v6, using params gives the right id in console, but the project displayed is wrong, heres an example:

example of displaced data

The "id: 7" is the project one and wrong, but the "6" below is the params id which is the correct one.

Here's the project page code:

export function ProjectPage() {
  const {projectId} = useParams();
  const project = filterData[projectId]
  const {title, mediaUrl} = project;
  console.log(project, projectId)

  return (
    <div className={"project-page-body"}>
      <div className={"project-page-title"}>
        <h1 className={"project-item-title"}>{title}</h1>
        <p className={"description"}>
          Lorem ipsum filler text for project description.
        </p>
      </div>
      <div className={"project-page-image"}>
          <img src={mediaUrl} style={{width: "80vw", height: "auto" }}/>
      </div>
    </div>
  );
}´´´
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Id(not paramsId) is a number type but paramsId(not Id) is a string type. You passed projectId, which is a string type, so you need to convert projectId to string type using toString() method.

about 4 years ago · Juan Pablo Isaza Denunciar

0

For future notices, the solution was turning projectId into an integer.

Here's the working code:

 const { projectId } = useParams();
  const [project, setProject] = useState();

  useEffect(() => {
    setProject(
      filterData.find((project) => project.id === parseInt(projectId))
    );
  }, [projectId]);
about 4 years ago · Juan Pablo Isaza Denunciar

0

Here you have done "const project = filterData[projectId]" which means projectId will act as index fot filterData array.So as index always starts from 0 so the next project is displayed.

So you can make it as "const project = filterData[projectId-1]"

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda