2016-08-30 24 views
0

jQuery Apiがひどく必要ですが、私はReact jsでapiを使用しています。私はReact js Lifecyclesを混乱させるだけです。 その他の情報異なるdivのビューカウンタを作成しています。私の視点では、私はひどく、jQueryのAPIを高さを世話するscrollTopスプライトを必要とする。.. 次のコードは出力不定はjQueryとReact jsの統合方法は?

var React = require('react'); 
var ReactDOM = require('react-dom'); 
var NewsDetail = require('./news-details'); 
var $ = require('jquery'); 


module.exports = React.createClass({ 
    getInitialState:function() { 

     return{ 
      news:[ 
       { 

       { 
        id:"5", 
        data:"I probably am using the wrong I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value terminology here but this is what I'm trying to do. I want to create a map with a value for each key and a value for each key's object. S" 
       }, 
       { 
        id:"6", 
        data:"I probably am using the wrong I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value terminology here but this is what I'm trying to do. I want to create a map with a value for each key and a value for each key's object. S" 
       }, 
       { 
        id:"7", 
        data:"I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value for each key and a value for each key's object. S" 
       }, 
       { 
        id:"8", 
        data:"I probably am using the wrong I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value terminology here but this is what I'm trying to do. I want to create a map with a value for each key and a value for each key's object. S" 
       }, 
       { 
        id:"9", 
        data:"I probably am using the wrong I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value I probably am using the wrong terminology here but this is what I'm trying to do. I want to create a map with a value terminology here but this is what I'm trying to do. I want to create a map with a value for each key and a value for each key's object. S" 
       }, 

      ], 
      top:0, 
      height:null 
     } 
    }, 
    componentWillMount:function() { 

    }, 
    componentDidUpdate:function() { 

     var height = $('#newscontainer').height(); 
     alert(height)//udefined 

    }, 
    render:function() { 

     var newsdata = this.state.news.map(function (newss) { 

      return(<NewsDetail key={newss.id} {...newss}/>) 
     }); 
     return(
      <div className="newscontanier" id="newscontanier">{newsdata}</div> 
     ) 



    } 

}) 
+2

をそれにもかかわらず、あなたは

<div ref={elem => this.elem = elem} className="newscontanier" id="newscontanier">{newsdata}</div> 

のようにこれを行うことができ、その後、あなたは見つけることができますか?要素の高さを取得しているだけの場合は、jQueryを使用せずに行うことができます。 –

+1

var height = $( '#newscontainer')。高さ();あなたのDOMによると、間違ったIDを選択しています。 ... id = "newscontanier" –

+0

あなたのIDはあなたのレンダリング機能で間違っています。 – ray

答えて

1

あなたがタイプミスnewscontanierを持つことになります。あなたはjQueryのを必要としないのはなぜDOM要素

this.elem.getDOMNode(); 
+0

getDOMNodeは[非推奨]です(https: //facebook.github.io/react/blog/2015/10/07/react-v0.14.html#dom-node-refs) – ray

+0

@rayわかりませんでした。とにかく 'this.elem'からDOMノードを取得できます –

関連する問題