Reputation: 5
I am using create-react-app and facing issue with react-router-dom. The problem is when I am trying to use Link or NavLink component I got this error:
For example Router and Route components from react-router-dom work fine.
package.json
{
"name": "pmboard-gui-bp3",
"version": "0.1.0",
"private": true,
"dependencies": {
"@blueprintjs/core": "^3.28.2",
"@blueprintjs/datetime": "^3.18.2",
"@blueprintjs/docs-theme": "^3.6.1",
"@blueprintjs/select": "^3.13.3",
"@blueprintjs/table": "^3.8.9",
"@material-ui/icons": "^4.9.1",
"axios": "^0.19.2",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"chart.js": "^2.9.3",
"chartjs-plugin-annotation": "^0.5.7",
"dotenv": "^8.2.0",
"file-saver": "^2.0.2",
"formik": "^1.5.8",
"history": "^4.10.1",
"moment": "^2.26.0",
"node-sass": "^4.14.1",
"prop-types": "^15.7.2",
"quill": "^1.3.7",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^6.1.0",
"react-quill": "^1.3.5",
"react-redux": "^7.2.0",
"react-rnd": "^10.1.10",
"react-router-dom": "^5.2.0",
"react-router-redux": "^4.0.8",
"react-scripts": "3.0.1",
"redux": "^4.0.5",
"redux-createreducer": "^2.0.0",
"redux-saga": "^1.1.3",
"yup": "^0.27.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
">0.2%",
"not dead",
"not op_mini all"
]
},
"devDependencies": {
"classnames": "^2.2.6",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"prop-types": "^15.7.2",
"redux-logger": "^3.0.6"
}
}
I tried to remove node_modules and install it again -> didnt work.
Any thoughts? I will provide any information if necessary.
Thank you very much in advance.
Upvotes: 0
Views: 515
Reputation: 4639
Changing from import Link from react-router-dom/modules/Link to import {Link} from "react-router-dom";
solved the issue.
even I would suggest to use NavLink from "react-router-dom"; while using Link you may face some issues. and It's recommended to use NavLink.
Upvotes: 1