2016-05-25 15 views
0

https://facebook.github.io/react/docs/events.htmlReactイベントの小道具にアクセスする

私はonMouseOverイベントとonMouseOUtイベントを使用しています。

... 
mouseOver(e) { 
    this.setState({hover: true}); 
} 

mouseOut(e) { 
    this.setState({hover: false}); 
} 

render() { 
... 
<NavItem 
    onMouseOver={this.mouseOver.bind(this)} 
    onMouseOut={this.mouseOut.bind(this)} 
    eventKey={0} href='#' 
</NavItem> 
... 

は、どのように私は2つのイベントの小道具、がscreenX

答えて

1

あなただけのバニラはJavaScriptのように、イベントのプロパティにアクセスすることができますようにプロパティを設定/アクセスします。

mouseOver(e) { 
    const screenX = e.screenX; 
    this.setState({hover: true}); 
} 

注:非同期イベントにアクセスしたい場合、あなたは、イベントハンドラの先頭でe.persist()を呼び出します。

関連する問題