usePerformanceObserver
Hook that allows you to observe performance entries
sensors
low
test coverage
Last changed: 42 minutes ago
TIP
This hook uses PerformanceObserver browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api
Installation
Library
CLI
Manual
typescript
import { usePerformanceObserver } from '@siberiacancode/reactuse';Usage
typescript
const { supported, entries, start, stop } = usePerformanceObserver();Demo
Api
Parameters
| Name | Type | Default | Note |
|---|---|---|---|
| options | UsePerformanceObserverOptions | - | The options for the performance observer |
| callback | PerformanceObserverCallback | - | The function to handle performance entries |
Returns
object
Type declaration
typescript
export type UsePerformanceObserverOptions = PerformanceObserverInit & {
/** Whether to start the observer immediately */
immediate?: boolean;
};Source
Source • DemoContributors
D