Created
October 24, 2018 15:46
-
-
Save pomber/9f225c660a570f17cb28035182c30c8a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 React from "react"; | |
import ReactDOM from "react-dom"; | |
import fetchWithCache from "./cache"; | |
function Post({ postId }) { | |
const post = fetchWithCache( | |
"https://jsonplaceholder.typicode.com/posts/" + postId | |
); | |
return ( | |
<div> | |
<h1>{post.title}</h1> | |
<p>{post.body}</p> | |
</div> | |
); | |
} | |
const rootElement = document.getElementById("root"); | |
ReactDOM.render( | |
<React.Suspense fallback={<div>Loading...</div>}> | |
<Post postId={1} /> | |
</React.Suspense>, | |
rootElement | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment