3
私はAJAX呼び出しを作成して、それを取得した後にビューに追加しようとしていました。リアクション - ユーザ定義のJSXコンポーネントレンダリングされていない
現在のコードでは何も起こりません。
const View =() => (
<div>
<h1>Reports</h1>
<statisticsPage />
</div>
);
export default View;
var statisticsPage = React.createClass({
getInitialState: function() {
return {info: "loading ... "};
},
componentDidMount: function() {
this.requestStatistics(1);
},
render: function() {
return (
<div>info: {this.state.info}</div>
);
},
requestStatistics:function(){
axios.get('api/2/statistics')
.then(res => {
values = res['data']
this.setState({info:1})
console.log('works!!')
});
}
})
どうもありがとう!魅力のように動作します。 3分で受け入れる – Acai
喜んで助けた –