Skip to content

Instantly share code, notes, and snippets.

@myogeshchavan97
Last active April 6, 2021 05:41
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 myogeshchavan97/0a00fceb0637a85b919e4d95b7f0752d to your computer and use it in GitHub Desktop.
Save myogeshchavan97/0a00fceb0637a85b919e4d95b7f0752d to your computer and use it in GitHub Desktop.
useContext UsersList
import React, { useContext } from 'react';
import UserItem from './UserItem';
import UserContext from '../context/UserContext';
const UsersList = () => {
const { users, isLoading } = useContext(UserContext);
return (
<div className="users-list">
{isLoading ? (
<p className="loading">Loading...</p>
) : (
<React.Fragment>
{users.map((user, index) => (
<UserItem key={index} {...user} />
))}
</React.Fragment>
)}
</div>
);
};
export default UsersList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment