Created
March 1, 2018 18:49
-
-
Save peggyrayzis/4c4778e88d9eb71b71b8974836fea044 to your computer and use it in GitHub Desktop.
placeholder for react async
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, { 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