Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
How can I get history of React Router Dom in Version 6 with React Class Component

I need to get history object. I am using version 6 of react-router-dom & I also installed react-router v6. Here this is my code of one class component.

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

class Blog extends Component {
    render() {
        console.log(this.props)
        return (
            <div>
                <h4>History</h4>
            </div>
        )
    }
}
const B = withRouter(Blog)
export default B

& I import it to another component.

import React, { Component } from 'react'
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import B from './pages/Blog'

class Lesson2 extends Component {
    render() {
        return (
            <BrowserRouter>
                <div>
                    <h4>Lesson 2</h4>
                    <MainNav />
                    <Routes>
                        <Route path='/blog/' element={<B />}/>
                    </Routes>
                </div>
            </BrowserRouter >
        )
    }
}

export default Lesson2

I am getting error Attempted import error: 'withRouter' is not exported from 'react-router' Although I install both react-router & react-router-dom.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!