1

There is component that displays a list of users.
It displays 10 users each.
Once I get to the bottom of the list, i want to add the next 10 items to the list.
I want it to feel like a messenger.
How can I determine the bottom of the list?

import React, { FunctionComponent } from 'react';
import { User } from 'components/molecules/User';
import { IUsers } from 'domain/room';

type Props = {
  users: IUser;
  onClickUser: (id: number) => void;
};
export const UserList: FunctionComponent<Props> = ({
  users,
  onClickUser,
}) => {
return (
       <div style={{ overflow: 'auto' }}>
            {users.map((user) => (
              <div key={user.id} onClick={() => onClickUser(user.id)}>
                <User
                  name={user.name}
                  img={user.pictureUrl}
                  status={user.status}
                />
              </div> 
        ))}
 );
}
import { Label } from 'components/atoms/Label';
import { RoundedIcon } from 'components/atoms/RoundedIcon';
import React, { FunctionComponent } from 'react';

type Props = {
  name: string;
  img: string;
  status: string;
};

export const User: FunctionComponent<Props> = ({
  name,
  img,
  status,
}) => {
  return (
    <div>
        <RoundedIcon size={65} url={img} />
        <Label weight={700} size={14}>
          {name}
        </Label>
        <Label size={12} height={18}>
          {status}
        </Label>
    </div>
  );
};
iiiuuuu
  • 11
  • 2
  • Do you already have all your users in memory or do you need to fetch the next 10? Do you know the total number of users? – victmo Nov 11 '20 at 03:33
  • Does this answer your question? [Detecting when user scrolls to bottom of div with React js](https://stackoverflow.com/questions/45585542/detecting-when-user-scrolls-to-bottom-of-div-with-react-js) – LMulvey Nov 11 '20 at 03:33
  • need to fetch.. – iiiuuuu Nov 11 '20 at 04:03

0 Answers0