2017-01-05 12 views
3

ハンドラ関数にイベントオブジェクトの代わりにプロキシオブジェクトを渡し反応させ(バージョン1.5.2を反応させる):「EVT」としてコンポーネントがIが反応次のコンポーネントを準備した

var QuickSearch = React.createClass({ 
 

 
    searchHandler: function(){ 
 
     this.props.parent.props.dataSource.search = this.refs.SearchInput.value; 
 
     this.props.parent.props.dataSource.setPage(1); 
 
     this.props.parent.getData(); 
 
    }, 
 

 
    refreshHandler: function(){ 
 
     this.props.parent.props.dataSource.search = this.refs.SearchInput.value; 
 
     this.props.parent.getData(); 
 
    }, 
 

 
    myEventHandler: function(evt){ 
 
     console.log(evt); 
 
     if(evt.keyCode === 13) { 
 
      evt.stopPropagation(); 
 
      this.searchHandler(); 
 
     } 
 
    }, 
 

 

 
    render: function(){ 
 

 
     /* Translation function from table model */ 
 
     _ = this.props.parent.props.table_model.gettrans; 
 

 
     return(
 
      <div className="reactable-quicksearch-wrapper"> 
 
       <input ref="SearchInput" type="text" onKeyPress={this.myEventHandler} placeholder={_('Search phrase...')} /> 
 
       <button ref="SearchButton" type="button" onClick={this.searchHandler}>{_('Search')}</button> 
 
       <button ref="RefreshButton" type="button" onClick={this.refreshHandler}>{_('Refresh')}</button> 
 
      </div> 
 
     ); 
 
    } 
 

 
});

myEventHandler機能を「ターゲット」(基本的に入力)とハンドラが含まれているプロキシオブジェクトが渡されます。

Proxy { <target>: Object, <handler>: Object } 

私はなぜ何も確信していませんが、s「のように振る舞うように見えますubmit "(??)とにかく、私が読んだことから標準的なイベントオブジェクトを渡すべきですが、そうではありません。

このような動作の原因は何ですか?

答えて

1

これは予期された動作です。 Reactはネイティブイベントを使用してブラウザの不一致を解消し、SyntheticEventを使用します。しかし、何か変わって見える。 IIRCクラス名は、プロキシではなくSyntheticEventです。

+0

は、プロキシ内に[105]です。 – PiWo

関連する問題