Hello I have an array of data:
my_tags = [
{
item: 1,
tags: {name: 'LandingPage', value: 'true'},
{name: 'Country', value: 'GB'},
{name: 'Carrier', value: 'Evri'},
{name: 'EventCode', value: 'Dispatched'},
},
{
item: 2,
tags: {name: 'LandingPage', value: 'true'},
{name: 'Country', value: 'USA'},
{name: 'Carrier', value: 'RoyalMail'},
{name: 'EventCode', value: 'Dispatched'},
}]
I have a react-table-v6 and trying to put in a each row tags[country.value] and tags[carrier.value]. Just want to have there list of countries and carriesrs. How to do it.
I tryed:
{
Header: 'Alert tags',
id: 'tags',
accessor: (data) => {
const res = data.tags.map(items => items.tags?.find(i => i?.name === 'Carrier').value);
console.log('res:', res);
},
}
But in console.log I have:
[undefined, undefined] <<< HERE IS PROBLEM
But I tested it it works if we do that. Just why it does not work in react-table-v6 through accessor:
const carriers = data3.map(item => {
return item.tags.find(tag => tag.name === 'Carrier').value
})
console.log(carriers) //[ 'RoyalMail', 'Evri']
Or I can easy put there for example all names
(accessor: item => (item.tags.map(i => i.name))