Skip to content

Instantly share code, notes, and snippets.

@marekpiechut
Created June 22, 2021 10:52
Show Gist options
  • Select an option

  • Save marekpiechut/ad7f5cbb08c9c15ac1225763397462c4 to your computer and use it in GitHub Desktop.

Select an option

Save marekpiechut/ad7f5cbb08c9c15ac1225763397462c4 to your computer and use it in GitHub Desktop.
React-profiler
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