Selecting a friend The selectedFriend state variable is used to track the friend currently selected for bill splitting. It is initialized using the useState hook, initially set to null as no friend is selected during the component's initial rendering...

Markdown supported · ⌘↵ to post
Ndeye Fatou Diop
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: