Skip to content

Instantly share code, notes, and snippets.

@Keldrik
Created August 5, 2019 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keldrik/b247ca2446fdc1cca434b2ea474a561a to your computer and use it in GitHub Desktop.
Save Keldrik/b247ca2446fdc1cca434b2ea474a561a to your computer and use it in GitHub Desktop.
import React from 'react';
import useDataFetch from './useDataFetch';
const app = () => {
const data = useDataFetch('https://jsonplaceholder.typicode.com/posts/1');
const postTitle = () => {
if (data) {
return <h2>{data.title}</h2>;
else {
return <h2>Daten werden geladen...</h2>;
}
};
return (
<div>
<h1>Fetch-Hook</h1>
<div>{postTitle()}</div>
</div>
);
}
export default app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment