clauderic / react-sortable-hoc

A set of higher-order components to turn any list into an animated, accessible and touch-friendly sortable list✌️
https://clauderic.github.io/react-sortable-hoc/
MIT License
10.77k stars 978 forks source link

TypeError: Cannot read properties of undefined (reading 'add') #862

Open ujwaldeepsc20y opened 1 year ago

ujwaldeepsc20y commented 1 year ago

Not sure why this error is coming up while using SortableElement. Here is the code snippet I am using

const DragHandle = SortableHandle(() => <span>::</span>);
const DraggableContainer = SortableContainer(({ children }) => {
  return <ul>{children}</ul>;
});
const DraggableElement = SortableElement(({ value }) => (
  <li value={value}>
    <DragHandle />
    {value}
  </li>
));

and here is how I am using the above components in render

render() {
    return (
        <DraggableContainer
          useDragHandle
          // getContainer={this.getContainer}
          // helperContainer={this.getHelperContainer}
          // onSortEnd={this.handleSortEnd}
        >
          <DraggableElement key={`item-1`} index={0} value={1} />
          <DraggableElement key={`item-2`} index={1} value={2} />
        </DraggableContainer>
    );
  }
Raviteja7714 commented 5 months ago

Facing the same issue after upgrading to react 18.. Uncaught TypeError: this.context.manager.add is not a function image