Giter Club home page Giter Club logo

why-did-you-update's Introduction

🌶️ This repo is no longer being maintained 🌶️

Good new though! You can go here where someone is maintaining a fork!

why-did-you-update's People

Contributors

amilajack avatar chrisblossom avatar garbles avatar jdalton avatar pgilad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

why-did-you-update's Issues

Gives warning when items are appended to list, causing rerender.

Hi, I'm wondering if this works when you append new items to a list.

I have a CollectionView:

const RowList = ({ rows }) => {
  return (
    <div>
      {rows.map(row => (
        <Row
          key={row.id}
          id={row.id}
          name={row.name}
        />
      ))}
    </div>
  );
};

Whenever I add items to the "rows" object, I want to render these rows.
By adding key={row.id}, React makes sure that components that are already rendered are not rerendered.
But unfortunately, why-did-you-update tells me that a part of the list is still the same, so I have to avoid the rerender:

RowPage.props.rows.0
deepDiff.js:38 Value did not change. Avoidable re-render!
RowPage.props.rows.1
deepDiff.js:38 Value did not change. Avoidable re-render!

etc.
Note that it gives this error on the component that contains the RowList, not on the RowList itself.

I'm wondering if the warning is correct and I should make changes to the data structure, or if why-did-you-update is giving me a false positive.

if define a Component has componentDidUpdate, the 'why-did-you-update' will not work..

Stopped working with function components

Somewhere after [email protected] the createClass is not called for function components anymore. It means that the original monkey-patch doesn't work. Today I tried to hack react-addons-perf for the same purpose and it seems to work fine so far. For anybody who might be interested:

// whyDidYouUpdate2.js
import get from 'lodash/get';
import { deepDiff } from 'why-did-you-update/lib/deepDiff';

export default (ReactDebugTool) => {
	const debugProps = {};

	const _onBeforeMountComponent = ReactDebugTool.onBeforeMountComponent;
	ReactDebugTool.onBeforeMountComponent = (
		function (debugID, element, ...args) {
			const componentName = get(element, 'type.displayName', get(element, 'type.name', ''));
			if (componentName && /^[a-zA-Z0-9]+$/.test(componentName)) {
				debugProps[debugID] = get(element, 'props');
			}
			_onBeforeMountComponent(debugID, element, ...args)
		}
	).bind(ReactDebugTool);

	const _onBeforeUpdateComponent = ReactDebugTool.onBeforeUpdateComponent;
	ReactDebugTool.onBeforeUpdateComponent = (
		function (debugID, element, ...args) {
			const componentName = get(element, 'type.displayName', get(element, 'type.name', ''));

			if (componentName && /^[a-zA-Z0-9]+$/.test(componentName)) {

				const prevProps = debugProps[debugID];
				const props = get(element, 'props');

				deepDiff(prevProps, props, componentName);

				debugProps[debugID] = props;
			}
			_onBeforeUpdateComponent(debugID, element, ...args);
		}
	).bind(ReactDebugTool);
}

Usage:

import whyDidYouUpdate2 from './whyDidYouUpdate2';

import ReactDebugTool from 'react-dom/lib/ReactDebugTool';
import Perf from 'react-addons-perf';

whyDidYouUpdate2(ReactDebugTool);
Perf.start();

Opt-in rather than ignore

Really neat idea, I like it!

However I feel like it's not necessarily ideal in real life to have it turned on for all components.
The ignore option is a nice one, but I'd rather have an include option or something similar that does the opposite: Opt-in for specific components.

Typically that would help if you're concentrating on optimising a given component rather than being polluted by other components.

What do you think?

support React Native

this is currently not working for me.
I'm getting an infinite stream of these logs and my app never boot:
screen shot 2016-05-23 at 15 18 19

Customizable console.warn vs console.error

Great plugin.

I would love an option to specify if "Value did not change" messages should go through console.error or console.warn. In React Native, a console.error call triggers the red error screen and kills the app.

I'm happy to implement this myself and send over a PR if you have an API in mind for user-configured settings.

Thanks

(false positive) Notification about avoidable re-render when updated props have unchanged nested object

When you have props with nested object which is shared between updates

const style = {height: "auto"};
...
// render
<Description text={text} style={style} />
...
// update with the reference to the same style property
<Description text={newText} style={style} />

why-did-you-update shows warning although re-render is unavoidable (style did not change, but other props do)

Description.props.styles
  "Value did not change. Avoidable re-render!"
  before Object {height: "auto"}
  after  Object {height: "auto"}

Should string comparison be different from regex?

Right now the package is normalising strings into regex values so it can use the same .test() method in shouldInlude(). I think it might give false positives because it's not an equality check anymore but it checks if the string is found in a component names. That means a string exclusion called 'Bar' will also match a component named 'FooBar'.

See also #14 for the reason why I'm opening this issue.

Problems with React 15.3.1 PureComponent

Hi!

when I use this package with PureComponent such as:

import { PureComponent } from 'react';

class MyComponent extends PureComponent {

}

I'm getting a warning for every prop, while switching to Component (without any componentShouldUpdate method) it just works as expected.

Crash when "Debug JS Remotely" is disabled

I always get this crash both o android and ios when I run the application in debug mode but I have not enabled "Debug JS Remotely". When I enable and refresh, than it works.
screen shot 2017-08-07 at 10 15 16 am

Link to a maintained repository in the README

This repository is very popular (over 5k stars as of mid '17) and issues and PRs are compounding as it is no longer maintained.

There are many forks to this repo which take care of some/all of these issues. It might be a good idea to add alongside "THIS IS NOT BEING MAINTAINED" a link to one of these repositories if the fork owner is comfortable moving it forward.

If you can recommend a working fork or run one yourself please mention that here, then we can create a PR to direct users to your repository instead.

Error: Cannot find module './deepDiff'

W20170107-14:20:00.841(8)? (STDERR) Error: Cannot find module './deepDiff'
W20170107-14:20:00.842(8)? (STDERR)     at require (packages/modules-runtime.js:109:19)
W20170107-14:20:00.842(8)? (STDERR)     at meteorInstall.node_modules.pretty-bytes.why-did-you-update.lib.index.js (packages/modules.js:24170:17)
W20170107-14:20:00.842(8)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:181:9)
W20170107-14:20:00.842(8)? (STDERR)     at require (packages/modules-runtime.js:106:16)
W20170107-14:20:00.843(8)? (STDERR)     at meteorInstall.lib.lib.js (lib/lib.js:21:29)
W20170107-14:20:00.843(8)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:181:9)
W20170107-14:20:00.843(8)? (STDERR)     at require (packages/modules-runtime.js:106:16)
W20170107-14:20:00.844(8)? (STDERR)     at app.js:6:1
W20170107-14:20:00.844(8)? (STDERR)     at /Users/monsterstep/dev/repos/dashboard-app-maker/.meteor/local/build/programs/server/boot.js:295:34
W20170107-14:20:00.844(8)? (STDERR)     at Array.forEach (native)
React = require('react')

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

Stop after 2k warnings

I tried with a slow React Native app receiving websocket data. After a few seconds and nearly 5,000 warnings it froze my laptop.

I'd like to pull request with a fix. Some ideas:

  • Warn once per component.
  • Debounce warnings in the notifier.
  • Set hard limit at 2k messages.

It could be opt-in, via option.

whyDidYouUpdate(React, {
    cutoffLimit: 2000,
})

whyDidYouUpdate(React, {
    oncePerComponent: true,
})

// etc

Group diffs by component first

When there are a large number of diffs, it could be useful to group them first by component, before grouping by the prop which changed.

A minimal implementation of this is:

diff --git a/src/index.js b/src/index.js
index 8db94a5..5a46514 100644
--- a/src/index.js
+++ b/src/index.js
@@ -27,7 +27,9 @@ function createComponentDidUpdate (opts) {
       diffProps(prevProps, this.props, displayName)
         .concat(diffState(prevState, this.state, displayName))

+    console.groupCollapsed(displayName)
     diffs.forEach(opts.notifier)
+    console.groupEnd()
   }
 }

But I am guessing a more robust (and possibly configurable?) solution would be better. Let me know if you think this feature is worth adding and I'm happy to put in a PR.

React 15.6 crashes

Getting this error after updating to the newly released version.
Anyone?

'lowPriorityWarning.js:40 Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0. Use a plain JavaScript class instead. If you\'re not yet ready to migrate, create-react-class v15.* is available on npm as a temporary, drop-in replacement. For more info see https://fb.me/react-create-class'
Uncaught TypeError: Cannot set property createClass of #<Object> which has only a getter
    at whyDidYouUpdate (index.js:41)
    at Object../components/stage.js (stage.js:10)
    at __webpack_require__ (bootstrap bb0dfdd…:659)
    at fn (bootstrap bb0dfdd…:85)
    at Object../app.js (app.js:1)
    at __webpack_require__ (bootstrap bb0dfdd…:659)
    at fn (bootstrap bb0dfdd…:85)
    at Object.0 (scaffolds.scss?f3be:26)
    at __webpack_require__ (bootstrap bb0dfdd…:659)
    at ../node_modules/ansi-html/index.js.module.exports (bootstrap bb0dfdd…:708)

Crash on React Native

Tried running this on React Native ver 0.45.1 (uses React 16.0.0-alpha.12). I receive the following error: Cannot set property createClass of # which has only a getter.

The error occures in ~/why-did-you-update/lib/index.js:41:4.

Any ideas what might be causing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.