Day 21 of 100days of code
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...
kaylah.hashnode.dev5 min read
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: