简体   繁体   English

在react-grid-layout中覆盖onMouseDown

[英]Overriding onMouseDown in react-grid-layout

How do I override onMouseDown for a GridItem? 如何为GridItem覆盖onMouseDown?

I have something like this: 我有这样的事情:

class TrackItem extends React.Component {
    onMouseDown(e) {
        this.props.onMouseDown.apply(e);
    }
    render() {
        return <div onMouseDown={this.onMouseDown.bind(this)}>item</div>;
    }
}

Which yields the error: 产生错误:

react-draggable.js:1050 Uncaught TypeError: Cannot read property 'button' of undefined react-draggable.js:1050 Uncaught TypeError:无法读取未定义的属性'button'

事实证明,我不需要apply

this.props.onMouseDown(e);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM