Last active
September 15, 2019 05:34
-
-
Save hrdtbs/b253e1135c61facdb5e3af98cd7d65f8 to your computer and use it in GitHub Desktop.
単純なReact.Suspenceの使用例
This file contains 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
let done = false | |
const LazyComponent = () => { | |
if (!done) { | |
throw new Promise(resolve => { | |
window.setTimeout(() => { | |
done = true | |
resolve() | |
}, 3000) | |
}) | |
} | |
return <p>Happy Suspence</p> | |
} | |
const App = () => { | |
return ( | |
<Suspence fallback={<p>wait 3m</p>}> | |
<LazyComponent /> | |
</Suspence> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment