Last active
April 6, 2021 05:41
-
-
Save myogeshchavan97/0a00fceb0637a85b919e4d95b7f0752d to your computer and use it in GitHub Desktop.
useContext UsersList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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