I have an array structured as follows:
const screens = [
{
name: 'John',
options: {
headerTitle: 'Book Title',
},
},
{
name: 'Bill',
options: {
headerTitle: 'Another title',
},
},
];
and a piece of data that I need to insert into the 'options:' above. The data I can reshape at will. It could be:
const header = {
headerStyle: {
borderBottomWidth: 0.5,
borderColor: 'black',
},
};
or
header2 = [
{
borderColor: 'red',
borderWidth: 0.5,
},
];
The end goal is to have:
const screens = [
{
name: 'John',
options: {
headerTitle: 'Book Title',
headerStyle: {
borderColor: 'red',
borderWidth: 0.5,
},
},
{
name: 'Bill',
options: {
headerTitle: 'Another title',
headerStyle: {
bordercolor: 'red',
borderWidth: 0.5,
},
},
];
I have been googling the spread operator but I don't seem to be able to get the two merged.