Created
June 22, 2021 10:53
-
-
Save marekpiechut/d61708865460dadf541712759beb9fff to your computer and use it in GitHub Desktop.
React-profiler
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
import { | |
unstable_trace as trace, | |
unstable_wrap as wrap, | |
} from 'scheduler/tracing' | |
<button | |
onClick={() => | |
trace('Fetch data', performance.now(), () => { | |
setLoading(true) | |
fetchData() | |
.then( | |
wrap(data => { | |
setData(data) | |
}) | |
) | |
.finally(wrap(() => setLoading(false))) | |
}) | |
} | |
> | |
Fetch data | |
</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment