---
title: "Comment by Ndeye Fatou Diop on \"Day 21 of 100days of  code\" | Hashnode"
description: "That is a very nice post! So generally, what I do is rather than storing the selected friend, I store the selected friend ID, and then I do selectedFriend = fri"
url: "https://hashnode.com/posts/day-21-of-100days-of-code/65c01273fa4650417f2f119d/comment/65c0218f6e571cc71eb6043d"
---

[Discussion](https://hashnode.com/posts/day-21-of-100days-of-code/65c01273fa4650417f2f119d)

Comment [Day 21 of 100days of code](https://hashnode.com/posts/day-21-of-100days-of-code/65c01273fa4650417f2f119d)

[Ndeye Fatou Diop](https://hashnode.com/@fatou)

[Feb 4, 2024](https://hashnode.com/posts/day-21-of-100days-of-code/65c01273fa4650417f2f119d/comment/65c0218f6e571cc71eb6043d)

That is a very nice post! So generally, what I do is rather than storing the selected friend, I store the selected friend ID, and then I do selectedFriend = friends.find(f => f.id === selectedFriendId) if needed. The benefits of this approach are:

-   you can’t end up with a selected friend that is no longer on the list
-   you always have the latest value of the selected friend. You could imagine that under the hood for a given ID, the selected friend object completely changes
-   you have a less complex state: that’s just a string
-   if you decide to have a component that renders a friend, it’s better to pass the ID vs the entire friend

[chioma christopher](https://hashnode.com/@Kaylah)

[Feb 5, 2024](https://hashnode.com/posts/day-21-of-100days-of-code/65c01273fa4650417f2f119d/comment/65c0218f6e571cc71eb6043d#reply-65c1491b8ad5cff3f01431f6)

Thank you so much for this ma'am. i added the correction below the blog and updated it. I really appreciate 🙏🙏. It works fine too now. Thank you for the knowledge shared🙏

[Ndeye Fatou Diop](https://hashnode.com/@fatou)

[Feb 5, 2024](https://hashnode.com/posts/day-21-of-100days-of-code/65c01273fa4650417f2f119d/comment/65c0218f6e571cc71eb6043d#reply-65c1577daf791544d48c699f)

[chioma christopher](https://hashnode.com/@Kaylah) glad you liked it ☺️
