Skip to content

Instantly share code, notes, and snippets.

@DJanoskova
Last active June 19, 2020 05:45
Show Gist options
  • Save DJanoskova/e46eb08fc4e7707dc6c0cb0b0d340413 to your computer and use it in GitHub Desktop.
Save DJanoskova/e46eb08fc4e7707dc6c0cb0b0d340413 to your computer and use it in GitHub Desktop.
import React, { useState, useEffect } from 'react'
import { fetchUserAction } from '../api/actions.js'
const UserContainer = () => {
const [user, 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