Last active
March 19, 2019 17:18
-
-
Save antoinejaussoin/6aa3b63e1deafdf53d059d87900fd704 to your computer and use it in GitHub Desktop.
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 { 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