I have an object like this:
{
'icon':'info',
'size':'small',
'content':'label'
}
I’m trying to split it up into an array of new objects where there is one property per object:
{'icon':'info'}, {'size':'small'} , {content':'label}
I thought I could do this using Object.entries like this:
Object.entries(controlsObject).map(prop => ({ prop }))
But it’s really not working out for me – is there another way? Where am I going wrong?
>Solution :
You should instead do this:
Object.entries(controlsObject).map(([key, value]) => ({ [key]: value }))