Forked from DJanoskova/CleanerComponents-UserContainer1.js
Created
May 11, 2020 00:28
-
-
Save virajkulkarni14/6accc63eef9acd24bbc848c9d7d78fc8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { useState, useEffect } from 'react' | |
| import { fetchUserAction } from '../api/actions.js' | |
| const UserContainer = () => { | |
| const [uset, setUser] = useState(null); | |
| const handleUserFetch = async () => { | |
| const result = await fetchUserAction(); | |
| setUser(result); | |
| }; | |
| useEffect(() => { | |
| handleUserFetch(); | |
| // eslint-disable-next-line react-hooks/exhaustive-deps | |
| }, []); | |
| if (!user) return <p>No data available.</p> | |
| return <UserCard data={user} /> | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment