Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141836

why undefined [object Object],[object Object] on react-redux?

$
0
0

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};
      };

Image


Viewing all articles
Browse latest Browse all 141836

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>