Dragula with react - Uncaught TypeError:react_dragula_1.default不是函数

时间:2016-08-28 22:23:52

标签: reactjs dragula react-dragula

我正在尝试测试Dragula,做出拖放和发现问题的反应。我收到了错误:

  

未捕获的TypeError:react_dragula_1.default不是函数

任何人都面临这个问题或解决问题的线索。

import * as React from "react";
import * as ReactDOM from 'react-dom';
import Dragula from 'react-dragula';

export class MultiPicklist extends React.Component {
    render() {
        return (<div className="swish-input-textarea">
                <div className='parent'>
                    <div className='wrapper'>
                        <div id='left-defaults' className='container' ref={this.dragulaDecorator} >
                            <div>Element 0</div>
                            <div>Element 1</div>
                            <div>Element 2</div>
                            <div>Element 3</div>
                        </div>
                        <div id='right-defaults' className='container'>
                            <div>Element a</div>
                            <div>Element b</div>
                            <div>Element c</div>
                            <div>Element d</div>
                            <div>Element e</div>
                        </div>
                    </div>
                </div>
                </div>);
    },
        dragulaDecorator = (componentBackingInstance) => {
            if (componentBackingInstance) {
                let options = { };
                console.log('componentBackingInstance');
                console.log(componentBackingInstance);
                Dragula([componentBackingInstance]);
             }
  };    

}

1 个答案:

答案 0 :(得分:0)

我看到你在使用ES6类语法时有点乱。尝试在类定义之外拉出ref回调:

q = a;               % q is basically a copy of a
q(~success,:) = 0;   % except the `non-success` rows are zero 
x(q) - x(a)          % suppose q and a store index, this will give you the substraction.

您也可以在类方法中使用ES6箭头函数,但为此您需要在Babel中启用实验性功能才能进行编译。 请查看此问题以获取更多详细信息:https://stackoverflow.com/a/31362350/4642844