0
My code is not working pls help
This is my first react code https://code.sololearn.com/WDXdj21vMJgb/?ref=app
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.
0
Josh Greig thanks