@fatou
Senior Frontend Engineer
Hi there 馃憢,
I have been a Software Engineer for more than five years now. For the past 3-4 years, my focus has been on Frontend Engineering.
I share tips to help overwhelmed junior front-end developers navigate their careers and reach the next level.
Nothing here yet.
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鈥檛 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鈥檚 just a string if you decide to have a component that renders a friend, it鈥檚 better to pass the ID vs the entire friend