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

275
Visualizações
React Router/History Can't Resolve "history/createBrowserHistory"

I cloned my react project today and the project was working fine on my other mac. Then I started to face some problems with my router, especially the history. The code in my history.ts is:

import createHistory from 'history/createBrowserHistory';

export default createHistory();

My app.tsxis:

import React from 'react';
import { Route, Router, Switch, } from 'react-router-dom';
import { connect } from 'react-redux';

import history from '../history';

const App = (props: any) => {
    return (
        <div>
            <Router history={history}>
                <div>
                    <Header/>
                    <Route path="/" exact component={Home}/>
                    <Route path="/about" exact component={About} />
                    <Route path="/media" exact component={Media}/>
                    <Switch>
                        <Route path="/login" exact component={Login}/>
                        <PrivateRoute path="/menu" exact component={Menu} auth={props.isSignedIn} />
                        <PrivateRoute path="/create" exact component={PostCreate} auth={props.isSignedIn} />
                        <PrivateRoute path="/delete/:id" exact component={PostDelete} auth={props.isSignedIn}/>
                    </Switch>
                </div>
            </Router>
        </div>
    );
};

I tried to change my history.ts to:

import { createBrowserHistory } from "history";
export default createBrowserHistory();

and no success, I also tried to change to

import { createBrowserHistory, History } from "history";
const history: History = createBrowserHistory();
export default history

And no success too, it's strange because my application was working fine months ago. I've searched all over Stack Overflow and no solution seems to fit. Any help will be appreciated.

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

0

I've solved, I noticed that the createBrowserHistory.d.ts weren't getting created. Probably because of my fault yarn install. I removed the project and re-cloned and installed the libraries using npmThen worked.

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