Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Attempted import error: 'withRouter' is not exported from 'react-router'

This is the code I am using for a register screen using React:

import React, { useCallback } from "react";
import { withRouter } from "react-router";
import app from "../Firebase/firebase";

const Register = ({history}) => {
    const handleSignup = useCallback(async event => {
        event.preventDefault()
        const { email, password } = event.target.elements;
        try {
            await app
                .auth()
                .createUserWithEmailAndPassword(email.value, password.value);
            history.push("/dashboard")
        } catch(error) {
            alert(error)
        }
    }, [history]);

    return (
        <div>
            <p>Register</p>
            <Form onSubmit={handleSignup}>
                <label>
                    Email
                    <input name="email" type="email" placeholder="Email" />
                </label>
                <label>
                    Password
                    <input name="password" type="password" placeholder="Password" />
                </label>
                <button type="submit">Register</button>
            </Form>
        </div>
    )
}

export default withRouter(Register)

I am getting the error mentioned in the title, what am I doing wrong here?

I'm also getting these errors when running npm i react-routerin the terminal: npm WARN @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.16.0 requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you need to downgrade react-router and react-router-dom to version 5.

npm install react-router@5
npm install react-router-dom@5

I don't think Cube.js is maintained anymore. Probably best to find a different platform

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda