I just started to add TypeScript on my React project, and I can't figure out of this error :
import {Link} from 'react-router';
Module '"/Users/.../node_modules/@types/react-router/index"' has no exported member 'Link'.
The Link
component exists in react-router
(the code is working), but TypeScript does not recognise it. I've added the @types/react-router
, and it seems not to implements the Link
. Any ideas ?
Extract from my package.json
:
"@types/react": "^15.0.25",
"@types/react-dom": "^15.5.0",
"@types/react-router": "^4.0.11",
"@types/reactstrap": "^4.3.4",
...
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-router": "^3.0.2",
"reactstrap": "^4.2.0"
...
"typescript": "^2.3.3",
You have react-router
version 3, but the @types package for version 4. Version 4 of react-router moved a lot of the library into the react-router-dom
package, which is why their types are not in the @types/react-router
v4 packages.
You should remove the incorrect type package with:
npm un @types/react-router
Then install the correct types with:
npm i --save-dev @types/react-router@3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With