react-resource-monitor

2.0.1 • Public • Published

React Resource Monitor

semantic-release npm version

When using head management libraries, such as react-helmet, it is possible for React hydration and re-renders to cause resources to be loaded multiple times. This package logs a warning if that happens.

Installation

yarn add react-resource-monitor

Usage

Add the following hook to start monitoring resources:

import { useResourceMonitor } from 'react-resource-monitor';
 
useResourceMonitor();

Settings

The useResourceMonitor() hook accepts an object with the following settings:

Option Description Default
initiatorTypes An array of initiatorType to check for duplicates. ['script', 'link', 'css']
ignoreQuery Ignore any query params when checking for duplicate resources. true
disable Disable the warnings (e.g. if process.env.NODE_ENV === 'production'). false

Browser Support

This package will not work for IE unless you polyfill PerformanceObserver.

Build setup

# Run tests 
yarn run test
 
# Run linting checks 
yarn run lint

Readme

Keywords

none

Package Sidebar

Install

npm i react-resource-monitor

Weekly Downloads

3,291

Version

2.0.1

License

MIT

Unpacked Size

22.3 kB

Total Files

19

Last publish

Collaborators

  • alexmendes