पर पुनः प्रतिपादन नहीं कर रहा है मेरे पास एक प्रतिक्रिया कक्षा है जो सामग्री प्राप्त करने के लिए एक एपीआई पर जा रही है। मैंने पुष्टि की है डेटा वापस आ रहा है, लेकिन यह फिर से प्रतिपादन नहीं:प्रतिक्रिया घटक राज्य परिवर्तन
var DealsList = React.createClass({
getInitialState: function() {
return { deals: [] };
},
componentDidMount: function() {
this.loadDealsFromServer();
},
loadDealsFromServer: function() {
var newDeals = [];
chrome.runtime.sendMessage({ action: "findDeals", personId: this.props.person.id }, function(deals) {
newDeals = deals;
});
this.setState({ deals: newDeals });
},
render: function() {
var dealNodes = this.state.deals.map(function(deal, index) {
return (
<Deal deal={deal} key={index} />
);
});
return (
<div className="deals">
<table>
<thead>
<tr>
<td>Name</td>
<td>Amount</td>
<td>Stage</td>
<td>Probability</td>
<td>Status</td>
<td>Exp. Close</td>
</tr>
</thead>
<tbody>
{dealNodes}
</tbody>
</table>
</div>
);
}
});
हालांकि, अगर मैं जोड़ने के एक debugger
नीचे की तरह, newDeals
भर जाते हैं, और फिर एक बार मैं जारी, मैं डेटा देखें:
loadDealsFromServer: function() {
var newDeals = [];
chrome.runtime.sendMessage({ action: "findDeals", personId: this.props.person.id }, function(deals) {
newDeals = deals;
});
debugger
this.setState({ deals: newDeals });
},
यह वही बुला सौदों सूची है:
var Gmail = React.createClass({
render: function() {
return (
<div className="main">
<div className="panel">
<DealsList person={this.props.person} />
</div>
</div>
);
}
});
दुह! मुझे पता होना चाहिए था कि यह मामला तब था जब डीबगर लाइन ने इसे ठीक किया था। बाध्य (यह) वह चीज थी जब मैंने पहली बार इसका प्रयास किया था। धन्यवाद, महान विस्तृत टिप्पणी! – brandonhilkert