Skip to content

Instantly share code, notes, and snippets.

@pomber
Created October 24, 2018 15:46
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 pomber/9f225c660a570f17cb28035182c30c8a to your computer and use it in GitHub Desktop.
Save pomber/9f225c660a570f17cb28035182c30c8a to your computer and use it in GitHub Desktop.
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