Created
December 16, 2022 18:27
-
-
Save chamerling/c55af57c28de03e48c5eaf15333cbb0a 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 { useState, useEffect, useCallback } from "react"; | |
import { withWebPerformance } from "./withWebPerformance"; | |
import Loader from "./components/Loader"; | |
export default function SomeComponent() { | |
const LoaderWithPerformance = withWebPerformance(Loader, "web-perf"); | |
const [loading, setLoading] = useState(true); | |
// ... | |
// TODO: load something and update the loading state | |
// | |
// callback when loader is complete | |
const onLoaded = useCallback((measure: PerformanceMeasure) => { | |
setLoadingTime(measure.duration); | |
}, []); | |
return ( | |
<div className="App"> | |
{loading ? ( | |
<LoaderWithPerformance onLoaded={onLoaded} /> | |
) : ( | |
<div> | |
{ /* ... */ } | |
</div> | |
)} | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment