Skip to content

Instantly share code, notes, and snippets.

@rayashi
Last active May 10, 2020 17:53
import React from "react";
export default ({ render, getContent }) => {
const [loading, setLoading] = React.useState(false);
const [content, setContent] = React.useState(null);
React.useEffect(() => {
async function load(){
setLoading(true);
const result = await getContent();
setContent(result);
setLoading(false);
}
load();
}, [getContent]);
if (loading || !content) {
return <p>Loading ...</p>;
}
return render(content);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment