Skip to content

Instantly share code, notes, and snippets.

@tpjnorton
Last active October 23, 2020 09:00
Show Gist options
  • Save tpjnorton/21ab6d6f2d069f7dafe9f1cbe20c2d7c to your computer and use it in GitHub Desktop.
Save tpjnorton/21ab6d6f2d069f7dafe9f1cbe20c2d7c to your computer and use it in GitHub Desktop.
useLoading Example
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