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

157
Vistas
React <Link> does nothing when clicking on it inside a map

in the Code below I am trying to use Link. The problem is, the first Link element does work, while the second Link element inside the map does not work. It does nothing when clicking on it. I searched a lot on different websites but could not find a reason why that is the case. Can anyone explain to me why this is the case and if there is a solution to my problem?

return (
    <div>
        <p><Link to='/test'>Testlink</Link></p>
        <div className={style.searchBarContainer}>
            <input className={style.searchBar} type="text" placeholder={placeholder} 
             onChange={handleChange} onFocus={handleFocusIn}
             onBlur={handleFocusOut}/>
            <div className={style.searchIcon}><i className="search icon"></i></div>
        </div>
        <div className={style.dataWindow}>
            {searchInput.map((value, key) =>{
                return(
                    <div className={style.dataItem} key={value.id}>
                        <p><Link to='/test'>{value.last_name}, {value.first_name}</Link></p>
                    </div>
                );
            })}
        </div>
    </div>
)

Thanks in advance

Alexej

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

0

You should use Link element on top lavel at least to provide a much wider hit area to click:

return (
    <div>
        <p><Link to='/test'>Testlink</Link></p>
        <div className={style.searchBarContainer}>
            <input className={style.searchBar} type="text" placeholder={placeholder} 
             onChange={handleChange} onFocus={handleFocusIn}
             onBlur={handleFocusOut}/>
            <div className={style.searchIcon}><i className="search icon"></i></div>
        </div>
        <div className={style.dataWindow}>
            {searchInput.map((value, key) =>{
                return(
                    <Link to='/test' key={value.id}>
                        <div className={style.dataItem}>
                            <p>{value.last_name}, {value.first_name}</p>
                        </div>
                    </Link>
                );
            })}
        </div>
    </div>
)
about 4 years ago · Juan Pablo Isaza Denunciar

0

Your code is working here in my CodeSandbox. The problem must be somewhere else.

about 4 years ago · Juan Pablo Isaza Denunciar

0

I found my mistake: The handleFocusOut function, that is executed onBlur, was used to hide the window in which there is the link I wanted to select. The onBlur was executed before the Link element, hid the window and therefore nothing happend after clicking on the link. I am now pausing the handleFocusOut function for 100ms so that the link gets executed first and now it works. I know this is not the best solution but it is the only one that worked unitl now. I will search for a better one. Thanks everyone for helping me :)

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