var prices = [];
$.getJSON("http://www.asterank.com/api/asterank?query={%22neo%22:{%22$lt%22:%22Y%22},%20%22price%22:{%22$gt%22:100000000}}&limit=1000", function(data) {
$.each(data, function(key,value) {
prices.push(value.price);
});
});
var App = React.createClass({
render() {
return(
<div className="app">
<div>
{console.log("logging price array")}
{console.log(this.props.priceData)}
{this.props.priceData.map(p => <PriceColumn price={p} />)}
</div>
</div>
)
}
});
var PriceColumn = React.createClass({
render() {
return(
<div>
<h4>{this.props.price}</h4>
</div>
)
}
})
ReactDOM.render(<App priceData={prices}/>, document.getElementById('container'));
我试图用json响应填充反应组件。这是“this.props.priceData”如何修复基于JSON响应的填充React组件?
Array[871]
[0 … 99]
0:
525905281.52797025
1:
604514917.0552349
2:
696637551.9520638
3:
875462960.8222823
4:
1267502400
5:
1332894080
6:
1467819274.5386994
7:
1498253120
8:
1703699200
9:
1743786240
10:
1864047360
11:
2725918720
12:
3191380043.7561345
13:
3652885251.1255836
14:
4587566603.506
每次我试图访问这个区域的数据点,我得到了一个未定义的执行console.log的一小段。谢谢您的帮助!
需要使用getIntialState方法,构造函数是es6类的语法方法 –
错过了那个,谢谢我编辑过。 –
真棒,这使得总体感。谢谢 –