Last active
August 16, 2019 06:45
-
-
Save samMeow/0abbc70b7cc2284653838b35f497afa2 to your computer and use it in GitHub Desktop.
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 from 'react'; | |
import ReactDOM from 'react-dom'; | |
let shouldRender = false; | |
const Children = () => { | |
if (shouldRender) { | |
return (<div>Hello world</div>); | |
} | |
throw new Promise((resolve) => { | |
setTimeout(() => { | |
shouldRender = true; | |
resolve(); | |
}, 2000); | |
}); | |
} | |
const App = ({ children }) => ( | |
<div> | |
<h1>Wait for something</h1> | |
<React.Suspense fallback={<span>Loading</span>}> | |
{children} | |
</React.Suspense> | |
</div> | |
); | |
ReactDOM.render(<App/>, document.getElementById('root')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment