我正在用React創建一個Github問題查看器。如何將json值傳遞到React組件
我有一個組件設置回購,然後我想創建單獨的組件來獲取問題的名稱,編號,登錄等。這些組件將最終在主要組件/視圖中使用。我有點卡住了,下面是我到目前爲止。
var GetRepo = React.createClass({
getRepo: function(){
var issues = $.getJSON('https://api.github.com/repos/facebook/react/issues', function (data) {
})
},
render: function() {
return <div>My repo: {this.props.repo}</div>
}
});
ReactDOM.render(<GetRepo repo="facebook/react/issues" />, document.getElementById('main'));
var IssueName = React.createClass({
});
//IssueName gets the data.title (the issue name) using repo GetRepo
var IssueNumber = React.createClass({
});
//IssueNumber gets the data.number (the issue number) using repo from GetRepo
什麼是你的問題?你卡在哪裏? – Nicholas
可能的重複[在加載數據之前如何防止組件呈現?](http://stackoverflow.com/questions/33131542/how-can-i-prevent-a-component-from-rendering-before-數據被加載) – Mathletics
這不是一個完全重複的問題,但我認爲這種類型的問題最容易通過容器組件解決方案解決。 – Mathletics