Can't access array in nested immutable object

Do that

render() {
        var elems = this.props.items.course_list;
        console.log(elems);
        return (
          <div>

          </div>
        )
      }

Result:

enter image description here

Try access to course_list by this:

render() {
        var elems = this.props.items.course_list;
        console.log(elems.course_list;);
        return (
          <div>

          </div>
        )
      }

Get undefined.

Have object course_list that include array course_list, I can't access to this array

This screen for

var elems = this.props.items; console.log(elems);

enter image description here

Upvotes: 0

Views: 146

Answers (1)

Shubham Khatri
Shubham Khatri

Reputation: 281646

You may need to convert the immutable object to a javascript object ot access the inner elements. In that case use getIn(). I hope it helps

var mystore = state.getIn(['incomeProfileList'])['course_list']; 
var copy = Object.assign({}, mystore); 
console.log(copy.course_list);

Upvotes: 1

Related Questions