-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Since the data doesn't contain an id field for each item, the workload is now generating keys for each <li> element dynamically while rendering, using uuidv4().
Speedometer/resources/newssite/news-next/src/components/article/article-content.jsx
Lines 23 to 32 in 3150f41
| {content.map((item) => | |
| <li key={uuidv4()} className={styles["article-list-item"]}> | |
| {item.url && !item.title | |
| ? <a href={item.url}> | |
| <ArticleText text={item.content} /> | |
| </a> | |
| : <ArticleText text={item.content} /> | |
| } | |
| </li> | |
| )} |
This will cause keys to never match up between renders, leading to these elements being recreated every time, which defeats the purpose of keys and slows the performance [1].
Besides, this implementation seems inconsistent with that of NewsSite-Nuxt, which uses item.id (which is undefined) as the key binding directly.
Speedometer/resources/newssite/news-nuxt/components/atoms/ArticleContent.vue
Lines 29 to 34 in 3150f41
| <li v-for="item in content" :key="item.id" :class="styles['article-list-item']"> | |
| <a v-if="item.url && !item.title" :href="item.url"> | |
| <ArticleText :text="item.content" /> | |
| </a> | |
| <ArticleText v-else :text="item.content" /> | |
| </li> |