react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

Uncaught TypeError: Cannot read property 'left' of undefined at WithSortableContainer.animateNodes

Open ashmitaggarwal opened this issue 3 years ago • 3 comments

How to get rid of this error. Due to which auto scroll also dont work.

ashmitaggarwal avatar Aug 20 '21 08:08 ashmitaggarwal

Same error with the latest version. @ashmitaggarwal have you solved it?

kishanbharda avatar Dec 09 '21 06:12 kishanbharda

Ok, I found the solution.

Initially, I was rendering SortableItem without any wrapper like this:

const SortableList = SortableContainer(({ items }) => {
  return items.map((value, index) => (
    <SortableItem
      key={`item-${value?._id}-${index}`}
      index={index}
      settingIndex={index}
      setting={value}
    />
  ))
});

Then I added a wrapper component around the SortableItem like below, and now it's working without error.

const SortableList = SortableContainer(({ items }) => {
  return (
    <div> // add any wrapper component
      {items.map((value, index) => (
        <SortableItem
          key={`item-${value?._id}-${index}`}
          index={index}
          settingIndex={index}
          setting={value}
        />
      ))}
    </div>
  );
});

kishanbharda avatar Dec 09 '21 06:12 kishanbharda

Ok, I found the solution.

Initially, I was rendering SortableItem without any wrapper like this:

const SortableList = SortableContainer(({ items }) => {
  return items.map((value, index) => (
    <SortableItem
      key={`item-${value?._id}-${index}`}
      index={index}
      settingIndex={index}
      setting={value}
    />
  ))
});

Then I added a wrapper component around the SortableItem like below, and now it's working without error.

const SortableList = SortableContainer(({ items }) => {
  return (
    <div> // add any wrapper component
      {items.map((value, index) => (
        <SortableItem
          key={`item-${value?._id}-${index}`}
          index={index}
          settingIndex={index}
          setting={value}
        />
      ))}
    </div>
  );
});

It work 👍🏻

phamthainb avatar Jun 19 '22 11:06 phamthainb