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
Passing state by history.push({..}) in TypeScript

I used history.push to redirect to my desired url and passed an information via the included state to the next route like this:

const history = useHistory()
history.push({
   pathname: '/someurl/',
   state: {
      foo: bar
   }
})

and in JavaScript this worked absolutely as expected. Now I am migrating this file to TypeScript and I am getting the following error:

Argument of type '{ pathname: string; state: { foo: bar; }; }'
is not assignable to parameter of type 'To'.

Object literal may only specify known properties, and
'state' does not exist in type 'PartialPath'

For some reason he thinks that I only pass a pathname without a state right? Does anyone know how to fix that?

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

0

Same issue resolved by after trying to fix it I found the problem appears when using custom history, like import history from 'history'; and then <Router history={history}>...</Router> So when I replaced it with <BrowserRouter>...</BrowserRouter> the problem disappeared.

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