Skip to content

Instantly share code, notes, and snippets.

@antoinejaussoin
Last active March 19, 2019 17:18
Show Gist options
  • Save antoinejaussoin/6aa3b63e1deafdf53d059d87900fd704 to your computer and use it in GitHub Desktop.
Save antoinejaussoin/6aa3b63e1deafdf53d059d87900fd704 to your computer and use it in GitHub Desktop.
import { useEffect, useState } from 'react';
export default () => {
const [activity, setActivity] = useState(null);
const fetchData = async () => {
const result = await fetch('http://someapi');
if (result.ok) {
const content = await result.json();
setActivity(content);
}
};
useEffect(() => {
fetchData();
}, []);
return { activity, next: fetchData };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment