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

229
Views
'react-router-dom' does not contain an export named 'useParams'

In App.js I have the following route:

<Route path="/Comp1/:catid">
    <Comp1 />
</Route>

This route can be called by clicking this link with a single parameter:

<Link to={'/Comp1/' + catid}>Comp1 </Link>

The parameter catid always has a certain value.

Comp1 is a component defined as follows:

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

export default class Comp1 extends Component {

    componentDidMount() {
        const params = useParams();
        const { catid } = params.catid;
        console.log(catid);
    }

    componentDidUpdate() {

    }

    render() {
        return (
            <div>
                Hello, I am class Comp1
            </div>
        );
    }
};

But what is happening now is at runtime, I am getting the following debug output:

'react-router-dom' does not contain an export named 'useParams'

--edit--

Installed version of react-router-dom is 4.2.2.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Definitely a version issue. Also discussed in this official issue.

Solution: Make sure you are using react-router-dom@>=5.1, since that particular hook was introduced in the 5.1 release.

If you have trouble getting modules installed at a proper version, then is the perfect time to practice just that, especially since it is very likely going to happen again and again, if you don't.

enter image description here

about 4 years ago · Juan Pablo Isaza Report
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!