M
M
Mashush2022-02-02 11:27:45
React
Mashush, 2022-02-02 11:27:45

How to make active link in react?

There is a site header with a number of links. To make a link active, you can write the following code to it:

<NavLink className={ ({isActive}) => isActive ? "link link--active" :  "link" } to="/...">Ссылка</NavLink>


But here's the problem - the header contains 2 links:

1. To the address /tasks 2.
To the address /tasks/create

tasks/create - both are highlighted. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2022-02-02
@Mashush

<NavLink className={({ isActive }) => isActive ? "link link--active" : "link"} to="/..." end>Ссылка</NavLink>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question