Coder Social home page Coder Social logo

Comments (7)

GuillaumeClementMontpellier avatar GuillaumeClementMontpellier commented on June 12, 2024 4

I got it too, because in Chrome, the mousemove events are fired a lot more rapidly if the devTools is open.

Linked to react-draggable #699

What happens, react-draggable doesn't pass by setState for tracking updated (because React 18 batch state updates), but react-grid layout does, which means the deltaX / deltaY that is passed is from the last mouseEvent, not the last state update.

For correction, react-grid-layout should now also use object mutation instead of react state in order to correctly track position.

from react-grid-layout.

soadzoor avatar soadzoor commented on June 12, 2024 2

for the record, today I started having the problems with 1.4.3 as well, so it's probably not a 100% solution

from react-grid-layout.

benedict-jackson avatar benedict-jackson commented on June 12, 2024 1

Looks like the solution to #1990

from react-grid-layout.

AndreiAyar avatar AndreiAyar commented on June 12, 2024

Switching react-draggable to 4.4.5 temporary seems to fix this.

from react-grid-layout.

soadzoor avatar soadzoor commented on June 12, 2024

Hey, any updates on this? I've spent 4 hours debugging my code, trying to figure out why my mouse is getting further and further away from the dragged object, then I narrowed it down to react, specifically if I change

const root = ReactDOM.createRoot(rootElement);

root.render(
	<App />
);

to
ReactDOM.render(<App/>, rootElement);

Then it's all good.

react-grid-layout-bug.mp4

The problem of course, is that we can't use ReactDOM.render in react 18 anymore. Should we downgrade to react 17, just because of this?

By the way, I had similar problems with drag and dropping three.js elements with my own code, especially when the dev tools was open. I also realized that the mousemove event is triggered much more frequently when dev tools are open in chrome.

My solution was pretty simple: keep track of the drag-start position of the mouse, and always check the latest coordinate of the mouse. This way it's kind of guaranteed that the dragged element will follow exactly the mouse. Even if there are minor errors frame by frame, they're not added up, because we only keep track of the first mouse position and the last one.

If anyone gets inspired by this, and creates a bugfix for this solution, I'd be eternally grateful.

from react-grid-layout.

soadzoor avatar soadzoor commented on June 12, 2024

As mentioned by someone in #1990 , downgrading this lib to 1.4.3 also solves this issue, so we can keep using react 18.

Not sure what exactly changed from 1.4.3 to 1.4.4 that affects this

from react-grid-layout.

ligoo avatar ligoo commented on June 12, 2024

someone found a way to make it work with React18? as ReactDOM.render is not available anymore and downgrading to 1.4.3 is having the same issue I can't see a temporary fix either.

from react-grid-layout.

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.