Skip to content

Instantly share code, notes, and snippets.

@peggyrayzis
Created March 1, 2018 18:49
Show Gist options
  • Save peggyrayzis/4c4778e88d9eb71b71b8974836fea044 to your computer and use it in GitHub Desktop.
Save peggyrayzis/4c4778e88d9eb71b71b8974836fea044 to your computer and use it in GitHub Desktop.
placeholder for react async
import React, { Fragment } from "react";
function Placeholder({ delayMs, fallbackUI, children }) {
return (
<React.Timeout ms={delayMs}>
{didTimeout => {
return (
<Fragment>
<span hidden={didTimeout}>{children}</span>
{didTimeout ? fallbackUI : null}
</Fragment>
);
}}
</React.Timeout>
);
}
export default Placeholder;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment