All Projects → maicki → Why Did You Update

maicki / Why Did You Update

Licence: mit
💥 Puts your console on blast when React is making unnecessary updates.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Why Did You Update

Caliper
Caliper is an instrumentation and performance profiling library
Stars: ✭ 162 (-96.04%)
Mutual labels:  performance, performance-analysis
Performance
⏱ PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.
Stars: ✭ 429 (-89.51%)
Mutual labels:  performance, performance-analysis
Hotspot
The Linux perf GUI for performance analysis.
Stars: ✭ 2,415 (-40.94%)
Mutual labels:  performance, performance-analysis
Heapinspector For Ios
Find memory issues & leaks in your iOS app without instruments
Stars: ✭ 1,819 (-55.51%)
Mutual labels:  performance, performance-analysis
Droidtelescope
DroidTelescope(DT),Android端App性能监控框架
Stars: ✭ 231 (-94.35%)
Mutual labels:  performance, performance-analysis
Tinydancer
An android library for displaying fps from the choreographer and percentage of time with two or more frames dropped
Stars: ✭ 1,859 (-54.54%)
Mutual labels:  performance, performance-analysis
Tracy
C++ frame profiler
Stars: ✭ 3,115 (-23.82%)
Mutual labels:  performance, performance-analysis
Lighthouse Monitor
Investigate performance over your whole company with lighthouse
Stars: ✭ 136 (-96.67%)
Mutual labels:  performance, performance-analysis
Perfview
PerfView is a CPU and memory performance-analysis tool
Stars: ✭ 2,924 (-28.49%)
Mutual labels:  performance, performance-analysis
Myperf4j
High performance Java APM. Powered by ASM. Try it. Test it. If you feel its better, use it.
Stars: ✭ 2,281 (-44.22%)
Mutual labels:  performance, performance-analysis
Deli
Stars: ✭ 148 (-96.38%)
Mutual labels:  performance, performance-analysis
Sparklens
Qubole Sparklens tool for performance tuning Apache Spark
Stars: ✭ 345 (-91.56%)
Mutual labels:  performance, performance-analysis
Nemetric
前端性能指标的监控,采集以及上报。用于测量第一个dom生成的时间(FP/FCP/LCP)、用户最早可操作时间(fid|tti)和组件的生命周期性能,,网络状况以及资源大小等等。向监控后台报告实际用户测量值。
Stars: ✭ 145 (-96.45%)
Mutual labels:  performance, performance-analysis
Speedracer
Collect performance metrics for your library/application.
Stars: ✭ 1,868 (-54.32%)
Mutual labels:  performance, performance-analysis
Fgprof
🚀 fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together.
Stars: ✭ 1,944 (-52.46%)
Mutual labels:  performance, performance-analysis
Fe Performance Journey
🚵 a Journey of Performance Optimizing in Frontend 🚀
Stars: ✭ 169 (-95.87%)
Mutual labels:  performance, performance-analysis
Pg stat kcache
Gather statistics about physical disk access and CPU consumption done by backends.
Stars: ✭ 106 (-97.41%)
Mutual labels:  performance, performance-analysis
Crossplatformdisktest
Windows, macOS and Android storage (HDD, SSD, RAM) speed testing/performance benchmarking app
Stars: ✭ 123 (-96.99%)
Mutual labels:  performance, performance-analysis
Torchfunc
PyTorch functions and utilities to make your life easier
Stars: ✭ 177 (-95.67%)
Mutual labels:  performance, performance-analysis
Quickperf
QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties
Stars: ✭ 231 (-94.35%)
Mutual labels:  performance, performance-analysis

Deprecated

why-did-you-update is now deprecated.

Please use @welldone-software/why-did-you-render instead. It supports the latest React, tracks hooks, and does much more to improve performance.

Why did you update

No Maintenance Intended Build Status npm version

Why-did-you-update is a function that monkey patches React and notifies you in the console when potentially unnecessary re-renders occur.

Setup

This library is available on npm, install it with: npm install --save why-did-you-update or yarn add why-did-you-update.

Sandbox

You can test the library >> HERE << (notice the console).

Version 1 Update With Breaking Changes

Check out the releases page.

We now only support React 16+

To work with older versions of react, install an older version of this library:

npm install --save [email protected] or yarn add [email protected]

Usage

import React from 'react';

if (process.env.NODE_ENV !== 'production') {
  const {whyDidYouUpdate} = require('why-did-you-update');
  whyDidYouUpdate(React);
}

Options

Optionally you can pass in options as a second parameter. The following options are available:

  • include: [RegExp]
  • exclude: [RegExp]
  • groupByComponent: boolean
  • collapseComponentGroups: boolean
  • notifier: (groupByComponent: boolean, collapseComponentGroups: boolean, displayName: string, diffs: [Object]) => void
include / exclude

You can include or exclude components by their displayName with the include and exclude options

whyDidYouUpdate(React, { include: [/^pure/], exclude: [/^Connect/] });
groupByComponent / collapseComponentGroups

By default, the changes for each component are grouped by component and these groups collapsed. This can be changed with the groupByComponent and collapseComponentGroups options:

whyDidYouUpdate(React, { groupByComponent: true, collapseComponentGroups: false });
notifier

A notifier can be provided if the official one does not suit your needs.

const notifier = (groupByComponent, collapseComponentGroups, displayName, diffs) => {
  diffs.forEach(({name, prev, next, type}) => {
    // Use the diff and notify the user somehow
  });
};
whyDidYouUpdate(React, { notifier });

Common Fixing Scenarios

Value Did Not Change

If you receive the message:

X.[props/state]: Value did not change. Avoidable re-render!`

About the props or the state object of component X, it means the component was rendered although the object is the same:

prevProps === props

or

prevState === state

Usually renders are caused because of the rendering of their father, or state change. In both cases, at least one of the two would change, at least by reference.

If both the state and the props are the same object, it means the render was caused by this.forceUpdate() or ReactDom.render():

prevProps === props && prevState === state

Not Equal by Reference

If you receive the message:

"X" property is not equal by reference.

This means it received a new object with the same value. For example:

const a = {"c": "d"}
const b = {"c": "d"}
a !== b

To avoid this warning, make sure to not recreate objects:

const a = {"c": "d"}
const b = a
a === b

Changes Are in Functions Only

If you receive the message:

Changes are in functions only. Possibly avoidable re-render?

It's probably because you are creating a function inside render:

render(){
  return <div fn={function something(){...}}/>
}

And this triggers a re-render because:

function something(){...} !== function something(){...}

You can avoid it by binding this function in advance and then reusing it on all renders

constructor(props){
  super(props)
  this.something = this.something.bind(this)
}
something(){
  ...
}
render(){
  return <div fn={this.something}/>
}

Credit

I originally read about how Benchling created a mixin to do this on a per-component basis (A deep dive into React perf debugging). That is really awesome but also tedious AF, so why not just monkey patch React.

License

why-did-you-update is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].