Skip to content

usePerformanceObserver

Category
Export Size
390 B
Last Changed
5 days ago

Observe performance metrics

Demo

Usage

tsx
import { 
usePerformanceObserver
} from '@reause/core'
import {
useState
} from 'react'
const [
entrys
,
setEntrys
] =
useState
<PerformanceEntry[]>([])
const {
isSupported
,
start
,
stop
} =
usePerformanceObserver
(
{
entryTypes
: ['paint'] },
list
=>
setEntrys
(
list
.
getEntries
()),
) // starts automatically (immediate: true by default) — stop() disconnects

Type Declarations

ts
export type UsePerformanceObserverOptions = PerformanceObserverInit & {
    window?: Window;
    immediate?: boolean;
}

export function usePerformanceObserver(options: UsePerformanceObserverOptions, callback: PerformanceObserverCallback)

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
72bf3 - fix(core): resolve usePerformanceObserver audit findings (#616)

Released under the MIT License. v0.1.8