File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -105,9 +105,8 @@ const SortableMixin = (options = defaultOptions) => (Component) => class extends
105105 } , 0 ) ;
106106 } ;
107107 } ) ;
108-
109- const domNode = ReactDOM . findDOMNode ( sortableComponent . refs [ this . sortableOptions . ref ] || sortableComponent ) ;
110- this . sortableInstance = Sortable . create ( domNode , copyOptions ) ;
108+ this . populatedOptions = copyOptions
109+ this . initSortable ( sortableComponent ) ;
111110 }
112111 componentWillReceiveProps ( nextProps ) {
113112 const sortableComponent = this . refs [ refName ] ;
@@ -120,12 +119,23 @@ const SortableMixin = (options = defaultOptions) => (Component) => class extends
120119 sortableComponent . setState ( newState ) ;
121120 }
122121 }
122+ componentDidUpdate ( ) {
123+ this . initSortable ( this . refs [ refName ] ) ;
124+ }
123125 componentWillUnmount ( ) {
124126 if ( this . sortableInstance ) {
125127 this . sortableInstance . destroy ( ) ;
126128 this . sortableInstance = null ;
127129 }
128130 }
131+ initSortable ( sortableComponent ) {
132+ if ( this . sortableInstance ) {
133+ this . sortableInstance . destroy ( ) ;
134+ this . sortableInstance = null ;
135+ }
136+ const domNode = ReactDOM . findDOMNode ( sortableComponent . refs [ this . sortableOptions . ref ] || sortableComponent ) ;
137+ this . sortableInstance = Sortable . create ( domNode , this . populatedOptions ) ;
138+ }
129139
130140 render ( ) {
131141 return (
You can’t perform that action at this time.
0 commit comments