Last active
May 6, 2022 18:11
-
-
Save dsvgit/fca793a0a65ea43566446fa549e41e18 to your computer and use it in GitHub Desktop.
React. Self-Invoking Functions for rendering.
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
const SelfInvokingChildren = () => { | |
const [loading, error, data] = useData() | |
return ( | |
<Layout> | |
{(function () { | |
if (loading) return <Placeholder /> | |
if (error) return <Error /> | |
if (!data) return <NotFound /> | |
return <PageContent data={data} /> | |
})()} | |
</Layout> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment