so i am making a following / followers component in my react code and using redux to manage the state, so lets say a user follows another user and my following model in my data base might look like this users following model
following: [
{
_id: "1213231235t34",
user: "242545367675445666",
username: "john",
email: "john@d.com"
},
{
_id: "625675676552",
user: "876869897976566",
username: "lenon",
email: "john@d.com"
},
{
_id: "1213231235t34",
user: "34536655344365654",
username: "mike",
email: "john@d.com"
},
{
_id: "1213231235t34",
user: "FINDTHIS",
username: "crease",
email: "john@d.com"
}
]
how can i find if the user(FIND THIS) is in the array and do something if it is found
for example the following model is like this when a user follows people
now if i go on the page of crease(THE LAST OBJECT IN THE ARRAY) i do not want to see a follow button, rather i want to see an unfollow button because he is already in my array of the users i am currently following. so how can i loop through the array and find the field of user(FINDTHIS)for the crease object... bascially i am asking how can i find if i am following crease... mind you i am using react so es6 syntax if you could help that would be wonderful... THANKS! if you do not understand the question please kindly ask for more info