I am using Next.js and mapping out some components with the below code. All works as it should but I would really like to destrcuture the object properties here to not be repeating the paths inside my props
{sortedData.map((service) => (
<Article
key={uuidv4()}
title={service.fields.title}
image={service.fields.thumbnail.fields.file.url}
alt={service.fields.thumbnail.fields.file.fileName}
slug={service.fields.slug}
content={service.fields.intro}
height={service.fields.thumbnail.fields.file.details.image.height}
width={service.fields.thumbnail.fields.file.details.image.width}
/>
))}
I tried looking for similar questions here but could not find any. Any help is appreciated
.map(({ fields: { title, ... } }) =>?service => { const fields = service.fields; const thumbFile = fields.thumbnail.fields.file; return …; }