I got a component where I need to pass data, searched in array. The array is stored in variable, and the data needs to go to Component prop. Consider the following;
const users = [
{"id": 1, "username": 'name1'},
{"id": 2, "username": 'name2'},
{"id": 3, "username": 'name3'},
{"id": 4, "username": 'name4'},
{"id": 5, "username": 'name5'}
]
const listItemData = [1,2,3];
<List
size="small"
bordered
dataSource={listItemData}
renderItem={item => <List.Item>{item}</List.Item>}//need name1, name2, name3 but get 1,2,3 here
/>
So here I have an array of users where all data about all users is stored, and array of particular list items where I have only ids. For rendering purposes I need to render usernames instead of ids. As far as I know I could iterate through user ids in components renderItem prop and show username of user that matches its id with id from listItemData.
Any ideas how to do that would be welcome. Thank you