Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

70
Vistas
I need one link to have different text depending on the current page

I have a website with two pages. When clicking on the nav link, I need the page and the nav link name to change. I tried this:

const [isClicked, setIsClicked] = useState(false);

const ClickHandler = () => {
    setIsClicked(!isClicked);
}

<NavLink to={isClicked ? '/' : '/profile'} onClick={ClickHandler}><NavPage>{isClicked ? 'Home': 'Profile'}</NavPage></NavLink>

but this showed me an error where when going to profile page. The link name and the actual link do not change, only the page changes, it has to be clicked again for everything to be ok.

Another problem when refreshing in the profile page the link name becomes profile again, I want it to be home.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

To keep the link between session, the value must be stored in localStorage or cookies, because now it depends on the state.

Maybe it'd be better to pass the target link via props?

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda