0

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

23
  • 5
    The ; within the console.log() is not valid, is it a typo? Commented Jan 26, 2017 at 12:20
  • yes, typo...... but not imoprtant it not working Commented Jan 26, 2017 at 12:22
  • could you try elems['course_list'] Commented Jan 26, 2017 at 12:22
  • 1
    elems is already course_list in your code. Commented Jan 26, 2017 at 12:26
  • 1
    To access course_list from elems, it should be declared as elems = this.props.items Commented Jan 26, 2017 at 12:28

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

8 Comments

import Immutable from 'immutable'
const mapStateToProps = function(state) { var mystore = state.toArray(); // console.log(mystore[6]); return { items: mystore[6] }; } this is how I get data
I have seen this, I am just thinking. maybe you can try state.toJS() and then see how you return item
what console.log must be to state?
so I said try var mystore = state.toJS() and then; try to get item from mystore. console.log(mystore) and share me the result.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.