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

214
Vistas
Refresh component on route only in React-Router V5

Is there a way to refresh a route when using react router v5. I have a onClick function which navigates to a route and refetches the data, however that is only if I use history.push('/') I want to refresh the component even if I am just on the same route '/' for example I am currently doing:

is there a better way to navigate programatically in react-router?

currently this handleChange method is in the header component.

const handleChange = (event: any) => {
    setValue(event.target.value);
    if (history.location.pathname === "/") {
        alert('Changing');
        // need to refresh component here?
    }
    history.push('/');
};

routing is:

 <QueryClientProvider client={queryClient}>
        <BrowserRouter>
          <Header links={items} locations={Locations} />
          <div className="App">
            <Switch>
              <Route exact path="/" component={home} />
              <Route path="/details/:id" render={(props: RouteComponentProps<any>) => <Detail {...props} />} />
              <Route component={NotFound} />
            </Switch>
          </div>
        </BrowserRouter>
        <ReactQueryDevtools />
      </QueryClientProvider>
about 4 years ago · Juan Pablo Isaza
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