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

Get `SortableContainer` usage straight

Open jasonslyvia opened this issue 9 years ago • 12 comments

Currently it seems SortableContainer is not working as desired

jasonslyvia avatar Sep 18 '16 00:09 jasonslyvia

Yes, the className and style are not set correctly.

chinesedfan avatar Sep 23 '16 02:09 chinesedfan

I have alse found this problem, please fix it...

lusyn avatar Sep 27 '16 07:09 lusyn

@jasonslyvia Hey, I check the issues associated with SortableContainer. I think the problem is that when you use React Component as your sortable item, you have to construct it manually.

Darmody avatar Oct 11 '16 21:10 Darmody

~~That means SortableContainer not work when:~~

  class SortItem { 
    ...
    render() {
      return (
         <SortableContainer>
           <MyOwnComponent />
         </SortableContainer>
      )
    }
  }

~~And @sortable is required for SortItem Component~~

Darmody avatar Oct 11 '16 21:10 Darmody

And this is why custom component don't work. https://github.com/jasonslyvia/react-anything-sortable/blob/master/src/index.js#L509-L512

Because If we pass props to a custom component, the component need to handle these props manually, that make no sense.

I think we can just always create a new <div> to accept sortable props.

Darmody avatar Oct 12 '16 17:10 Darmody

Or pass a component into SortableContainer to determine what element should SortableContainer be.

Darmody avatar Oct 12 '16 17:10 Darmody

@Darmody Can you explain why SortableContainer is exported directly as DemoContainerItem? I don't think your test usage is the same with the README in #77.

chinesedfan avatar Oct 13 '16 10:10 chinesedfan

@chinesedfan I think it is the same. What confuse you?

Darmody avatar Oct 13 '16 16:10 Darmody

@chinesedfan Oh I got your point, you are right.

Darmody avatar Oct 13 '16 17:10 Darmody

Sorry, I confused SortableContainer myself too... Actually it already wrapped by sortable mixin.

So we should put SortableContainer directly as Sortable's children, not inside the SortableItem.

Darmody avatar Oct 13 '16 18:10 Darmody

This whole SortableContainer thing is designed for avoiding React's warning since 15.2.0 IIRC.

jasonslyvia avatar Oct 13 '16 19:10 jasonslyvia

#58 for reference

jasonslyvia avatar Oct 13 '16 19:10 jasonslyvia