API 呼び出しから返された結果で 1 つの配列項目を取得するのに問題があります。
これがアクションの機能です。
followCheckList:function(userId){
for(var i= 0; i < userId.length;i++ ){
return{
types: [C.FOLLOW_CHECK_LIST, C.FOLLOW_CHECK_LIST_SUCCESS, C.FOLLOW_CHECK_LIST_FAIL],
promise: (client)=> client.get(`/graph/me/follows/${userId[i]}`)
.then(result => {
return result.id;
})
}
}
}
私の減速機
case C.FOLLOW_CHECK_LIST:
return{
...state,
follow_check_list:null,
error:false,
};
case C.FOLLOW_CHECK_LIST_SUCCESS:
return{
...state,
//break here
error:false,
follow_check_list: action.result
};
case C.FOLLOW_CHECK_LIST_FAIL:
return{
...state,
follow_check_list:false,
error:action.error,
};
default: return state || {loading: false,
loaded: null,
list_loaded: null};
}
私は2つの結果を期待しているfollow_check_list : action.result
ので、私の状態では見る必要があります
follow_check_list : Array[2].
0: item1,
1: item2
しかし、代わりに次のように表示されます。
follow_check_list : Array[1].
0: item1,
私のコンポーネントを更新します。arrayIds には 2 つの項目があります。
let arrayIds=[];
const FollowStatus = React.createClass ({
componentWillMount(){
arrayIds.push(this.props.status);
},
componentDidMount(){
this.props.followCheckList(arrayIds)
},
よろしくお願いします