2016-07-22 51 views
0

如何爲GridItem重寫onMouseDown?在react-grid-layout中覆蓋onMouseDown

我有這樣的事情:

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

其產生錯誤:

react-draggable.js:1050 Uncaught TypeError: Cannot read property 'button' of undefined

回答

0

原來我不需要apply

this.props.onMouseDown(e);