Skip to content

Commit

Permalink
docs(react): provide unique key instead of index
Browse files Browse the repository at this point in the history
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/)
  • Loading branch information
ThejasKiranPS committed Oct 30, 2022
1 parent edc0686 commit 181dd10
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/react/your-first-app/2-taking-photos.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ With the photo(s) stored into the main array we can display the images on the sc
<IonGrid>
<IonRow>
{photos.map((photo, index) => (
<IonCol size="6" key={index}>
<IonCol size="6" key={photo.filepath}>
<IonImg src={photo.webviewPath} />
</IonCol>
))}
Expand Down

0 comments on commit 181dd10

Please sign in to comment.