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

195
Vistas
React router dom with Typescript using match

I am using React Router Dom version 5 with React v 17 and with TypeScript. I am trying to figure out how to use the match object. So far I have:

import { BrowserRouter, Route, Switch, match } from 'react-router-dom';


interface DetailsProps {
  match?: match<string> ;
}

const Routing: React.FunctionComponent<DetailsProps> = (props: DetailsProps) => {
   const match = props.match;

   // more routes here
   <Route path={`${match.url}`} render={() => <Component/>} />
}

I get there error: Object is possibly 'undefined'.

Any Idea's why? is the type wrong?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can import it:

import { match } from 'react-router-dom';
about 4 years ago · Juan Pablo Isaza Denunciar

0

Your interface says that match is an optional param and can be undefined

interface DetailsProps {
  match?: match<string> ;
}

By removing ? mark you'll make it required:

interface DetailsProps {
  match: match<string> ;
}
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