Git Product home page Git Product logo

Comments (1)

blegesse-git avatar blegesse-git commented on June 12, 2024

Inside TableGraphTable.tsx there is an event listener function handleHover that gets executed each time the mouse moves. In other words, as the mouse hovers over a new cell, this function gets called. handleHover receives an event parameter, which contains a dataset property. And this dataset property we get from the event has a rowIndex property. When user moves the mouse to the first row of the table, rowIndex get updated from it's initial value to 0 -- indicating user is now on the first row of the able. Then when user moves the mouse cursor to the second row of the table, handleHover event listener gets executed and updates the rowIndex to be 1. Each time handleHover runs, we also update a state hoveredColumnIndex and hoveredRowIndex to be +dataset.columnIndex and +dataset.rowIndex respectively. Movement of the mouse from one row to another fireshandleHover function, which updates the state with the dataset.rowIndex value. But because we are updating the state and the state is attached to each cell of the table, it causes the component to re-render. This re-render then executes the handleHover function once again, which ends up updating the state with the previous row index value. Again, when state is updated, each cell gets re-rendered and this time the current row mouse is pointing to gets updated with the correct index value causing the jump we see in the UI.

from giraffe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.