Ares
Ares

Reputation: 31

Module '"react-router-dom"' has no exported member 'useSearchParams'

I want to make sure to redirect a user to a url by using useSearchParams, but it's not letting me import it!

I'm getting this error: (Module '"react-router-dom"' has no exported member 'useSearchParams').ts(2305), when I try to import it:

import { useSearchParams } from 'react-router-dom';

Upvotes: 3

Views: 2042

Answers (1)

Drew Reese
Drew Reese

Reputation: 202638

useSearchParams is a RRDv6 hook. Ensure you've correctly installed react-router-dom@6 as a dependency in your project. From the root project directory run the following command to install the latest RRDv6 version and update/save your package.json file.

npm install --save react-router-dom@6

Upvotes: 3

Related Questions