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

112
Vistas
How to navigate by using withRouter in reactJS while clicking on button react-router 6.2.1

How to navigate by using withRouter in reactJS while clicking on button react-router 6.2.1.

I am using react "react-router": "^6.2.1","react-router-dom": "^6.2.1",

I am getting error by

export 'withRouter' (imported as 'withRouter') was not found in 'react-router-dom'

Here is my code.

import React, { Component } from "react";
import { withRouter } from 'react-router-dom'; 

class myTab extends Component {
constructor(props) {
    super(props);
        this.state = {};
}

createNew = () =>{
    this.props.history.push(`/new/`);
}

render() {
    return (
      <div>
        <nav class="navbar navbar-expand-lg navbar-light bg-light">
            <div class="container-fluid">
                <button type="create" class="btn btn-primary" width="300"  onClick={this.createNew}> New </button>
               
            </div>
          
        </nav>
      </div>
    );
  }
}

export default withRouter(myTab);

Even though I am downgrading react router to 5.2 I am getting the same errror.

What options i have to fix this.

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