まだグーグルアウトできていないのではないかと疑っていますが、componentWillMount()メソッドを使用して還流ストアを使用して状態を更新したいこの反応コンポーネントがあります。
ストアの状態を更新することはできますが、 this.trigger を使用してストアから状態を更新しても、データの更新された状態が得られず、混乱しました。データの更新された状態を取得するにはどうすればよいですか。
現時点での私のコンポーネントは次のとおりです
var Challenges = React.createClass({
contextTypes: {
router: React.PropTypes.func
},
mixins: [Reflux.connect(ChallengeStore,'challenges')],
getInitialState: function() {
return {
challenges: []
}
}
componentDidMount: function() {
var trackId = this.props.params.trackId; // the url
ChallengeActions.GetChallenges(trackId);
console.log(this.state);
},
render: function () {
return(
<div>
<h1>{ this.state.challenges.title }</h1> <List challenges={ this.state.challenges } />
</div>
);
}
});
そして私のお店はこちら
var ChallengeStore = Reflux.createStore({
listenables: ChallengeActions,
onGetChallenges: function(url) {
var items = ChallengeService.getChallenges(url);
this.trigger({
challenges: items
});
}
});