0

Simple enough question. I am trying to read the value of the "length" variable inside this array of objects (See Image 1)

enter image description here

MY CODE

const mapStateToProps = (state, ownProps) => {

    const lecture = state.firestore.ordered.lectures;
    const length = lecture.length;

    return {

        length: length,

    }
}
Andrew B.
  • 245
  • 3
  • 12

1 Answers1

0

WHILE WRITING THIS QUESTION I FOUND THE SOLUTION:

SOLUTION CODE

const mapStateToProps = (state, ownProps) => {


    const length = state.firestore.ordered.lectures && state.firestore.ordered.lectures.length;



    return {

        length: length,

    }
}
Andrew B.
  • 245
  • 3
  • 12