2.0.1 • Published 4 years ago

react-resource-monitor v2.0.1

Weekly downloads
634
License
MIT
Repository
github
Last release
4 years ago

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:

OptionDescriptionDefault
initiatorTypesAn array of initiatorType to check for duplicates.['script', 'link', 'css']
ignoreQueryIgnore any query params when checking for duplicate resources.true
disableDisable 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
2.0.1

4 years ago

2.0.0

4 years ago

1.1.1

4 years ago

1.0.2

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago