S
S
saiasasd2021-12-13 14:40:36
React
saiasasd, 2021-12-13 14:40:36

react-router-dom not working?

Hello.
I create a clean project with npx create-react-app. Immediately after that I write in the terminal npm install react-router-dom. I look in package.json - it is installed. I go to app.js and change the a (learn react) tag to a link tag. As a result, the application does not start (I did not forget the import)
PS When importing several components from react-router-dom (import {Link, Route, BrowserRouter} from "react-router-dom", WebStorm for some reason highlights Link with a separate color (yellow) , and all others are greyed out.
61b7303da59d7524500671.png
61b7306de0374191843792.png
61b730908613b616424236.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Ukolov, 2021-12-13
@saiasasd

Well, they wrote to you in red and white - you can use Link only inside the Router component, outside it it makes no sense and cannot work. You should go back to the documentation: https://reactrouter.com/docs/en/v6/getting-started...

For some reason, WebStorm highlights Link with a separate color (yellow), and all the others are gray.
Imported but not used modules are grayed out.

F
FilinSnow, 2021-12-13
@FilinSnow

check you have import React instead of React

M
Mashush, 2021-12-15
@Mashush

BrowserRouter no

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question