Skip to content

Commit 181dd10

Browse files
committed
docs(react): provide unique key instead of index
As providing index as keys is a bad practice, this commit modifies the key value to be `photo.filepath` which will be unique and consistent while adding new photos. [Keys - react docs](https://reactjs.org/docs/lists-and-keys.html#keys) [example why it is not recommended](https://robinpokorny.com/blog/index-as-a-key-is-an-anti-pattern/)
1 parent edc0686 commit 181dd10

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/react/your-first-app/2-taking-photos.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ With the photo(s) stored into the main array we can display the images on the sc
131131
<IonGrid>
132132
<IonRow>
133133
{photos.map((photo, index) => (
134-
<IonCol size="6" key={index}>
134+
<IonCol size="6" key={photo.filepath}>
135135
<IonImg src={photo.webviewPath} />
136136
</IonCol>
137137
))}

0 commit comments

Comments
 (0)