-7

I want to access this.props.userList and populate it in List component, anyone know how?

here's the screenshot of the props.userList

enter image description here

angry kiwi
  • 10,730
  • 26
  • 115
  • 161
  • 3
    [Access / process (nested) objects, arrays or JSON](http://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json) – Jonathan Lonowski Apr 10 '16 at 20:33

2 Answers2

1

What about obj.ul[0].firstName and obj.ul[0].id?

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
  • 2
    This is really another kind of question which doesn't have anything to do with the previous one. You should create another question. – Marco Bonelli Apr 10 '16 at 20:43
  • 1
    then your answer is wrong, error Uncaught TypeError: Cannot read property 'firstName' of undefined – angry kiwi Apr 10 '16 at 20:46
  • the code: console.log(this.props.userList.ul[0].firstName); – angry kiwi Apr 10 '16 at 20:47
  • 1
    My answer is right for your original question. Editing the question changing it entirely is not a good thing to do. This is not how you ask here on Stack Overflow, you should either delete it or create a new question. – Marco Bonelli Apr 10 '16 at 20:48
  • Also, if you are getting a `Cannot read property xx of undefined` error then your object isn't the one you have attached to your question. – Marco Bonelli Apr 10 '16 at 20:51
  • it's the same object. Just check – angry kiwi Apr 10 '16 at 20:53
  • 1
    Nope man, **it isn't**. The screenshot you have attached shows that the object actually **contains** values. If you get that error, then that's not the object you screenshoted. – Marco Bonelli Apr 10 '16 at 20:56
0

the object you have has one key named ul inside that there is an array ,

the items inside the array have the key firstname:

you access it with o.ul[0].firstName

or if you want to loop:

for (i=0; i<o.ul.length; i++)
o.ul[i].id;
maioman
  • 18,154
  • 4
  • 36
  • 42