The Problem:
This is how the App is supposed to render the contacts, organized by sections according to their first name letters - A,B,C... So far i couldn't figure a way to diplay them in this way from A to Z. Neither changing the JSON structure or in ReactJS solved it. Every attempt to add more properties in the JSON, faced the limitation of Array.map one time "scaning". Any help is appreciated!
This is the JSON behind it:
[
{
"id": 1,
"fname": "Amanda",
"lname": "Gonzales",
"contact": "(31) 9 9580-2530",
},
{
"id": 2,
"fname": "Astrid",
"lname": "Guzman",
"contact": "(31) 9 9790-2530",
},
{
"id": 3,
"fname": "Aurora",
"lname": "Muñoz",
"contact": "(57) 9 9580-2530",
},
]
And the React JS as well:
class ShowContactsList extends Component {
render() {
const mappedJSON = mockData.map((inputMap, index) => (
<ContactListOneContact
key={index}
lname={inputMap.lname}
fname={inputMap.fname}
fname={inputMap.fname}
contact={inputMap.contact}
/>
));
return (
<div style={{ backgroundColor: 'yellow', width: '80%' }}>
<h1>A</h1>
{mappedJSON}
</div>
)
}
}

mockDatawhole component rerenders, endless loop may occur. Try toconsole.log(mappedJson)and see what it returns. Move this mapping function to somewhere else, as class function or best refactor component to functional component.