Home > database >  Getting an error with history module while using webpack dev server
Getting an error with history module while using webpack dev server

Time:11-23

I am trying to run webpack dev server and I'm getting this error. History was working properly before i started using webpack module.

WARNING in ./src/history.js 2:15-35 export 'createBrowserHistory' (imported as 'createBrowserHistory') was not found in 'history' (possible exports: default) @ ./src/App.js 18:0-32 91:17-24 @ ./src/index.js 4:0-24 11:20-23

History was working properly before i started using webpack module.

history.js

import { createBrowserHistory } from "history";

export default createBrowserHistory({ forceRefresh: true });

App.js

import React, { Component } from "react";
import { Route, Routes, unstable_HistoryRouter as HistoryRouter } from "react-router-dom";
import Cookies from "universal-cookie";
import history from "./history";
import LoginComponent from "./Components/login/login";
import Authenticate from "./Components/authenticate/authenticate";
import Callback from "./Components/Callback/callback";
import Home from "./Components/home/home";
import "./App.css";
import axios from "axios";


class App extends Component {
    constructor(props) {
        super(props);
        this.state = {};
        this.cookies = new Cookies();
        
    }

    
    render() {
        return (
            <div>
                <HistoryRouter history={history}>
                    <Routes>
                        {/* <Route path="/login" element={<LoginComponent />} /> */}
                        <Route path="/authenticate" element={<Authenticate />} />
                        <Route path="/users/twitter_callback" element={<Callback />} />
                        
                    </Routes>
                </HistoryRouter>
            </div>
        );
    }
}

export default App;

index.js

import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import "bootstrap/dist/css/bootstrap.min.css";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
    // <React.StrictMode>
    <App />
    // </React.StrictMode>
);


reportWebVitals();

any help will be apreciated

CodePudding user response:

For anyone with this same issue. I solved it by putting the history file in a sub directory and renaming it. like this "./history/browserHistory.js". This is a github issue about it https://github.com/remix-run/history/issues/793

  • Related