April 2020
Intermediate to advanced
716 pages
18h 55m
English
To display the who to follow feature, we will create a component called FindPeople, which can be added to any of the views or rendered on its own. In this component, we will fetch the users not being followed by calling the findPeople method in useEffect, as shown in the following code.
mern-social/client/user/FindPeople.js:
useEffect(() => { const abortController = new AbortController() const signal = abortController.signal findPeople({ userId: jwt.user._id }, { t: jwt.token }, signal).then((data) => { if (data && data.error) { console.log(data.error) } else { setValues({...values, users:data}) } }) return function cleanup(){ abortController.abort() } }, [])
The fetched list of users will be iterated over and rendered ...
Read now
Unlock full access