I have an arry :
classesAll:[0:{id:1,title:'test1'},1:{id:2,title:'test2'}]
It dosent return the excepted value of my array when I 'console.log(this.props.classes.classesAll)' it to console. Instead it shows the following : undefined [object Object],[object Object]
async componentDidMount() {
await this.props.showAllClasses();
console.log("***", this.props.classes.classesAll)
}
Redux action:
export const showAllClasses = () => {
return async dispatch => {
dispatch(pageLoading(true));
await Api.get(`classes.php`).then(res => {
//this.state.all = res.data;
const classesAll = res.data.data;
state.classesAll = classesAll;
});
await dispatch(onChangeClasessAll(state.classesAll));
dispatch(pageLoading(false));
};
};
export const onChangeClasessAll = classesAll => {
const type = CLASSES_ALL;
return { type , classesAll};
};