Here is the simple App.js code:
import React from 'react'
import Member from './Member'
function App () {
const members = [
{ name: 'Andy', age: 22 },
{ name: 'Bruce', age: 33 },
{ name: 'Mary', age: 11 }
]
for (const member of members) {
return <Member {...member} />
}
}
export default App
Here is the Member.js:
import React from 'react'
function Member ({ name, age }) {
return (
<div>
{name}
<hr />
{age}
</div>)
}
export default Member
The problem is only the first object {name:'Andy', age: 22} shows in the browser. How can I change the code to show all three of them?
I am new to Javascript and React. I just can't figure it out. Can anyone help? Thanks a lot.