[英]How to Integrate jQuery with React js?
I badly need jQuery Api's, but the thing is I have use that api with React js. 我非常需要jQuery Api,但是问题是我在React js中使用了该api。 I am just confusing my React js Lifecycles. 我只是在混淆我的React js生命周期。 Additional Info I am creating view counter for different div. 附加信息我正在为不同的div创建视图计数器。 In my Point of View I badly need jQuery api's to take care the height, ScrollTop.. The following code will output Undefined 在我看来,我非常需要jQuery api来照顾ScrollTop的高度。以下代码将输出Undefined
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>
)
}
})
You have typo newscontanier
. 你有错字newscontanier
。 Nonetheless you can do this like 不过,您可以像这样
<div ref={elem => this.elem = elem} className="newscontanier" id="newscontanier">{newsdata}</div>
and then you can find dom element 然后您可以找到dom元素
this.elem.getDOMNode();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.