Skip to content
Advertisement

I can’t import Link attribute from react-router-dom

I tried to import Link from react-router-dom & got compile error whether that module is not found. Then I installed it separately. Then got this error.

JavaScript

My code:

index.js

JavaScript

navBar.jsx

JavaScript

products.jsx

JavaScript

Advertisement

Answer

Before you can use the link tags, you first need to create a react router parent called <Routes> (v6) or <BrowserRouter> & <Switch> (v5). In this parent you can define your routes.

View this example:

https://stackblitz.com/github/remix-run/react-router/tree/main/examples/basic?file=src%2FApp.tsx

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement