Skip to content

Commit

Permalink
format code & remove superfluous commented lines #101 #66
Browse files Browse the repository at this point in the history
  • Loading branch information
blahosyl committed Aug 11, 2024
1 parent 3474e14 commit c4329aa
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions src/pages/profiles/ProfileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import Container from "react-bootstrap/Container";
import appStyles from "../../App.module.css";
import styles from "../../styles/ProfileList.module.css";
import Asset from "../../components/Asset";
import { useProfileData, useSetProfileData } from "../../contexts/ProfileDataContext";
import {
useProfileData,
useSetProfileData,
} from "../../contexts/ProfileDataContext";
import Profile from "./Profile";
import { Link } from "react-router-dom/cjs/react-router-dom.min";
import { useCurrentUser } from "../../contexts/CurrentUserContext";
Expand All @@ -23,8 +26,8 @@ const ProfileList = () => {
return (
// only render the component if a user is logged in
currentUser && (
<Container
className={`
<Container
className={`
${appStyles.Content}
${styles.Container}
// overflowY: "scroll"
Expand All @@ -40,44 +43,39 @@ const ProfileList = () => {
</h3>
</Link>
<InfiniteScroll
children={profileList.results.map(
(profile) =>
profile &&
/* list of users excluding the logged-in user */
Number(profile.id) !== Number(currentUser.pk) && (
<Profile
key={profile.id}
profile={profile}
setProfileData={setProfileData}
/>
)
)}
dataLength={profileList.results.length}
// loader={<Asset spinner />}
loader={"InfiniteScroll is loading more profiles..."}

// height={400}
hasMore={!!profileList.next}
endMessage={"You have viewed all teammates"}
// scrollableTarget="scrollableDiv"
// function in `next` by John Rearden
next={async () => {
try {
const { data } = await axiosReq.get(profileList.next);
setProfileData(prev => ({
...prev,
profileList: {
next: data.next,
results: [...prev.profileList.results, ...data.results]
},

}))
} catch (err) {
console.log(err);
}
}
}
/>
children={profileList.results.map(
(profile) =>
profile &&
/* list of users excluding the logged-in user */
Number(profile.id) !== Number(currentUser.pk) && (
<Profile
key={profile.id}
profile={profile}
setProfileData={setProfileData}
/>
)
)}
dataLength={profileList.results.length}
loader={<Asset spinner />}
hasMore={!!profileList.next}
endMessage={"You have viewed all teammates"}
// scrollableTarget="scrollableDiv"
// function in `next` by John Rearden
next={async () => {
try {
const { data } = await axiosReq.get(profileList.next);
setProfileData((prev) => ({
...prev,
profileList: {
next: data.next,
results: [...prev.profileList.results, ...data.results],
},
}));
} catch (err) {
console.log(err);
}
}}
/>
</>
) : (
// indicate if component is still loading
Expand Down

0 comments on commit c4329aa

Please sign in to comment.