tajo / react-movable

🔀 Drag and drop for your React lists and tables. Accessible. Tiny.
https://react-movable.pages.dev
MIT License
1.53k stars 51 forks source link

Does not work with React/Fast Refresh #47

Open rookbreezy opened 4 years ago

rookbreezy commented 4 years ago

I'm wondering if anyone has got it working with react refresh?

I'm using Next.js and everything is working with fast refresh except react-movable. Tried with react beautiful dnd and that works fine.

I'm forced to fully reload the page every time I change something in a react-movable .

purellarohith commented 2 years ago

I have same issue. Is there any way to resolve it?

rookbreezy commented 2 years ago

@purellarohith I ended up using https://github.com/atlassian/react-beautiful-dnd instead

timmeade commented 2 years ago

I have same issue. I tried both react-beutiful-dnd and react-dnd and this one works far better on mobile. I even tried with using source instead of npm and it still does not reload if using componets passed to:

import RenderList from './RenderList';
import RenderItem from './RenderItem';

<List
  lockVertically
  values={items}
  onChange={({ oldIndex, newIndex }) =>
    setItems(arrayMove(items, oldIndex, newIndex))
  }
  renderList={RenderList}
  renderItem={RenderItem}
/>

Code works great. Just no fast refresh in next.

timmeade commented 2 years ago

I wonder if somewhere in npm there is an incorrect case. That seems to be #1 reason to cause this.

rookbreezy commented 2 years ago

I tried both react-beutiful-dnd and react-dnd and this one works far better on mobile.

A trick I did to make it work better on mobile is forking beautiful-dnd and setting timeForLongPress to 0. This removes the delay when dragging on mobile.