Skip to content

Instantly share code, notes, and snippets.

@koss-lebedev
Last active July 11, 2022 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koss-lebedev/e311f7e6569ae1e7b04c1276140f04a8 to your computer and use it in GitHub Desktop.
Save koss-lebedev/e311f7e6569ae1e7b04c1276140f04a8 to your computer and use it in GitHub Desktop.
const getOnlyActive = (users) => {
const weekAgo = new Date()
weekAgo.setDate(weekAgo.getDate() - 7)
return users.filter(user => !user.isBanned && user.lastActivityAt >= weekAgo)
}
const ActiveUsersList = () => {
const { users } = useUsers()
return (
<ul>
{getOnlyActive(users).map(user =>
<UserItem key={user.id} user={user} />
)}
</ul>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment