Search code examples
javascriptreactjsreact-grid-layout

Overriding onMouseDown in react-grid-layout


How do I override onMouseDown for a GridItem?

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


Solution

  • It turns out I don't need apply:

    this.props.onMouseDown(e);