Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@welldone-software/why-did-you-render

Package Overview
Dependencies
Maintainers
3
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@welldone-software/why-did-you-render

Monkey patches React to notify you about avoidable re-renders.

  • 6.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
391K
decreased by-11.36%
Maintainers
3
Weekly downloads
 
Created

What is @welldone-software/why-did-you-render?

@welldone-software/why-did-you-render is a tool for debugging unnecessary re-renders in React applications. It helps developers identify and fix performance issues by logging information about why a component re-rendered.

What are @welldone-software/why-did-you-render's main functionalities?

Basic Setup

This code sets up the @welldone-software/why-did-you-render package to track all pure components in a React application. It helps in identifying unnecessary re-renders by logging detailed information.

const React = require('react');
const whyDidYouRender = require('@welldone-software/why-did-you-render');

whyDidYouRender(React, {
  trackAllPureComponents: true,
});

Tracking Specific Components

This code demonstrates how to track a specific component for unnecessary re-renders. By setting the static property `whyDidYouRender` to true, the package will log information whenever `MyComponent` re-renders.

import React from 'react';
import whyDidYouRender from '@welldone-software/why-did-you-render';

whyDidYouRender(React);

class MyComponent extends React.Component {
  static whyDidYouRender = true;
  render() {
    return <div>{this.props.text}</div>;
  }
}

Customizing Log Output

This code customizes the log output by including and excluding specific components. It also enables logging when prop values change. This helps in fine-tuning the debugging process to focus on specific parts of the application.

import React from 'react';
import whyDidYouRender from '@welldone-software/why-did-you-render';

whyDidYouRender(React, {
  logOnDifferentValues: true,
  include: [/^MyComponent$/],
  exclude: [/^SomeOtherComponent$/],
});

Other packages similar to @welldone-software/why-did-you-render

Keywords

FAQs

Package last updated on 14 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc