0

My code is not working pls help

This is my first react code https://code.sololearn.com/WDXdj21vMJgb/?ref=app

5th Nov 2020, 12:49 PM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar
2 odpowiedzi
+ 3
Replace your List with the following: function List(props){ const items=props.items const listitems = items.map((val,index)=> <li key={index.toString()}>{val}</li> ); return( <ul>{listitems}</ul> ); } Here are some of the changes: - I made your key value a string by calling toString(). The index you used was a number. - Your items.map was actually generating [undefined, undefined] because you used {} brackets without a return statement. I removed the {} brackets to fix that. - I added a ul element to wrap around your list items.
6th Nov 2020, 2:12 AM
Josh Greig
Josh Greig - avatar
0
Josh Greig thanks
7th Nov 2020, 11:13 AM
Yash Arora🇮🇳
Yash Arora🇮🇳 - avatar