Skip to content

usePerformanceObserver ​

Hook that allows you to observe performance entries

sensors
test coverage
Last changed: last month

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

NameTypeDefaultNote
optionsUsePerformanceObserverOptions-The options for the performance observer
callbackPerformanceObserverCallback-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 • Demo

Contributors ​

D
debabin
debabin

Released under the MIT License.