Last active
October 23, 2020 09:00
-
-
Save tpjnorton/21ab6d6f2d069f7dafe9f1cbe20c2d7c to your computer and use it in GitHub Desktop.
useLoading Example
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 {asyncA, asyncB} from './api' | |
const ComponentWithLoading = () => { | |
const [doA, aLoading] = useLoading(asyncA); | |
const [doB, bLoading] = useLoading(asyncB); | |
useEffect(() => { | |
doA(); | |
doB(); | |
}, []); | |
if (aLoading || bLoading) | |
return null; // or some fallback component | |
return ( | |
// ...your real component content | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment