Comments (7)
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.
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.
Looks like the solution to #1990
from react-grid-layout.
Switching react-draggable to 4.4.5 temporary seems to fix this.
from react-grid-layout.
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.
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.
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)
- [rtl resize] In RTL resize, when I try to shrink it, it gets bigger instead
- Positioning and Resizing does not work as intended in production mode HOT 2
- The performance of the grid layout is adversely affected when dealing with large SVG grid elements (size ≥ 1MB). HOT 5
- dragging working not correct HOT 10
- Setting item height based on rowHeight in OnResize is buggy HOT 1
- The x,y coordinate of the item is incorrect
- When columns are thin and column spacing is set, items move from their grid position when clicked HOT 3
- Issue with Red Color Popover on Item Click in Versions 1.4.3 and Above HOT 7
- [feature request] Drop onto another widget
- Dynamic static changes on children do not change children rendering HOT 3
- Grid item shifts leftward unexpectedly when dragging leftward resize handle.
- Responsive Grid Layout not working.. HOT 2
- React-grid-layout, antd dynamic form list HOT 1
- Upgrading dependencies causes react-grid-layout Responsive to crash with babel-loader error HOT 3
- Have errors in utils.js && ReactGridLayout.js HOT 3
- This repo should have updates for React 18+ HOT 4
- I have maxRows, but still its allow me to add more rows
- React 19 - Each child in a list should have a unique "key" prop. HOT 1
- There are no option for double click on specific grid element.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-grid-layout.