Мне очень нужен jQuery Api, но дело в том, что я использую api с React js. Я просто запутываю свой 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>
)
}
})
Зачем вам нужен JQuery? Если вы просто получаете высоту элемента, вы можете сделать это без jQuery. –
var height = $ ('# newscontainer'). Height(); выбирает неправильный идентификатор, согласно вашему DOM. ... id = "newscontanier" –
Ваш идентификатор ошибочно написан в вашей функции рендеринга. – ray