Skip to content

Instantly share code, notes, and snippets.

@kmoskwiak
Last active May 12, 2020 18:53
Show Gist options
  • Save kmoskwiak/5c61fe955cbccd28b340f11bb46922b7 to your computer and use it in GitHub Desktop.
Save kmoskwiak/5c61fe955cbccd28b340f11bb46922b7 to your computer and use it in GitHub Desktop.
import React, { useEffect, useState } from "react";
const App = () => {
cosnt [article, setArticle] = useState({});
useEffect(() => {
fetch('https://api.example.com')
.then(res => res.json())
.then(data => setArticle(data));
});
return (
<div>
{ article.title }
</div>
);
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment