reactjsreact-sortable-hoc

Is there a way to disable sorting in react-sortable--hoc


I have a requirement where the sorting of the list depends on the state which can be toggled using a button. The user should be able to sort only when he is in the editing mode. So I need to disable the sorting of the list. Can anyone help me out on how to add the disabled key to the SortableElement in react-sortable-hoc. I tired to search a working example on google but couldn't find any. Can anyone out there help me out on this one?.


Solution

  • From reading the documentation, seems like SortableElement supports a disabled flag, you could set the disabled flag to:

    <SortableItem ... disabled={editable}/>
    

    Where SortableItem is a wrapper of SortableElement.

    If you notice how SortableElement is defined, it just takes config where you can just pass the disabled flag. Hopefully this solves your issue.