---
title: "Discussion on \"Day 21 of 100days of  code\" | Hashnode"
description: "Discussion on \"Day 21 of 100days of  code\". Hello and welcome to day 21 of my challenge! 💪 Let's continue from where we left off yesterday."
url: "https://hashnode.com/posts/day-21-of-100days-of-code/65c01273fa4650417f2f119d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Day 21 of 100days of code](https://kaylah.hashnode.dev/day-21-of-100days-of-code?utm_source=hashnode&utm_medium=feed)

Hello and welcome to day 21 of my challenge! 💪 Let's continue from where we left off yesterday.

Feb 4, 2024 · 5 min read · kaylah.hashnode.dev  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#100daysofcode](https://hashnode.com/tag/100daysofcode)
-   [#beginners](https://hashnode.com/tag/beginners)

## Written by

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

@Kaylah

  
[View profile](https://hashnode.com/@Kaylah)

Frontend developer

## Responses 1

Markdown supported · ⌘↵ to post

[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 ☺️
