I have a component Post
that imports useParams()
from react-router-dom
. However, when I try to assign useparams()
to a const to see the params I have it throws the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'basename')
Here is how I am importing an assigning the params:
import { BrowserRouter as useParams } from "react-router-dom";
const { params } = useParams();
Here is my Post component:
import { BrowserRouter as useParams } from "react-router-dom";
class Post extends React.Component {
...
render() {
const { params } = useParams();
console.log(params)
return(
...
)
}
}
export default Post;
I am using:
"react": "^18.2.0"
"react-router-dom": "^6.4.3"
"react-dom": "^18.2.0"