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

124
Vistas
react onmouseover while onmousedown

I'm trying to implement the same effect google sheets and ms excel has, that you press on one cell and move the mouse to highlight other close cells, the problem is when the onMouseDown event is fired and I'm still holding the mouse down and move the mouse over other cells - the onMouseOver cannot be fired, the mouse cursor itself turns into the not-allowed sign, any suggestions how to solve it?

Test.js

import React, { useRef } from 'react'

function Test() {
    const myTable = useRef(null)
    return (
            <>
            <table ref={myTable}>
                <tbody>
                    {
                        [...Array(4)].map((row, rowIndex) => (
                            <tr>
                                {
                                    [...Array(4)].map((col, colIndex) => (
                                        <td style={{
                                            border: '1px black solid',
                                            width: '100px',
                                            height: '100px'
                                          }}
                                            onMouseDown={(e) => console.log('mouse down')} 
                                            onMouseOver={(e) => console.log('mouse over')}>
                                        </td>
                                    ))
                                }
                            </tr>
                        )

                        )
                    }
                </tbody>
            </table>
        </>
    )
}

export default Test

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

0

problem solved by adding e.preventDefault()

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