Last active
October 23, 2022 16:16
-
-
Save dioxmio/32474493244b21f4d9753ebd88922d41 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
// simulates a fetch | |
function fetchData() { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve({foo: 'bar'}); | |
}, 500) | |
}); | |
} | |
// component wrapped with a parent <Suspense /> | |
function Test() { | |
const data = use(fetchData()); | |
// ✅ no need for a nullcheck of data | |
return (<div>Result is {data.foo}</div>) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment