why-did-you-render

why-did-you-render by Welldone Software monkey patches React to notify you about potentially avoidable re-renders. (Works with React Native as well.)

MIT License

Downloads
1.8M
Stars
10.8K
Committers
37

Bot releases are visible (Hide)

why-did-you-render - added support to React.forwardRef

Published by vzaidman about 5 years ago

  • updated all dev packages.
  • minor refactor of inner code where patching of different react component types moved to it's own folder.
    • also split the main testing file between these patches.
  • added support to React.forwardRef.
  • added support to React.memo(React.forwardRef. (thanks to @jared-hexagon who filed a great bug report)
  • added support to React.forwardRef(React.memo but turns out React itself doesn't supports it.
  • everything is covered by tests.
why-did-you-render -

Published by vzaidman about 5 years ago

  • fixed renderToStaticMarkup
  • updated readme and console log phrasing
  • updated all packages
why-did-you-render -

Published by vzaidman over 5 years ago

Minor error reporting improvement by @jared-hexagon. Thanks!

why-did-you-render - Added TypeScript support

Published by vzaidman over 5 years ago

A contribution of @leroydev
Thank you!

why-did-you-render - Fixed strict mode and binded render scenarios

Published by vzaidman over 5 years ago

handled classes throwing false positives in StrictMode (https://github.com/welldone-software/why-did-you-render/issues/16)

handled binded render functions this.render.bind(this) in constructor

why-did-you-render - Updated all dev-dependencies

Published by vzaidman over 5 years ago

Mostly to fix a security vulnerability github found in the project

why-did-you-render -

Published by vzaidman over 5 years ago

v3.0.8 had unintended braking change to the CJS version where the require was an object that consisted of default and defaultNotifier so it had to be used like this:

whyDidYouRender.default(React) // unintended 3.0.8 use that has been fixed.

This is fixed in v3.0.9.
defaultNotifier is exported on the whyDidYouRender instead and the CJS library version can be used like this again:

whyDidYouRender(React);
const defaultNotifier = whyDidYouRender.defaultNotifier;
why-did-you-render -

Published by vzaidman over 5 years ago

  • updated dev dependencies
  • now exporting defaultNotifier (thanks @JoelBrenstrum)

unintended braking changes. see v3.0.9 above

why-did-you-render -

Published by vzaidman over 5 years ago

minor fix-
react inspect of components with hooks won't crash anymore

why-did-you-render -

Published by vzaidman over 5 years ago

Updated demos, examples, tests, and readme

why-did-you-render -

Published by vzaidman over 5 years ago

Fixed reporting of hooks about an inner WDYR component for hooks in non-memoized functional components

why-did-you-render -

Published by vzaidman over 5 years ago

  • Added react-redux tests + demo
  • When a React element is re-created as a property of another react element:
    • If it's props are different, ignore it.
    • if it's props are (deep or strict) equals, notify about the props + that the element shouldn't be re-created.
    • Updated + Added tests for this scenario
  • Improved memoized functional components tracking performance
  • Fixed memoized functional components and hooks reporting about an inner WDYR component.
why-did-you-render -

Published by vzaidman over 5 years ago

updated packages and readme

why-did-you-render -

Published by vzaidman over 5 years ago

fixed using of more then 2 hooks in a component

why-did-you-render -

Published by vzaidman over 5 years ago

improved hooks patching performance

why-did-you-render - React Hooks tracking is here!

Published by vzaidman over 5 years ago

Changes

  • wdyr now tracks re-renders that are caused by React hooks!

you can read about it >> HERE <<

  • titleColor / diffNameColor / diffPathColor - options now allow to change the colors of wdyr console notifications.
why-did-you-render - Added support to React.memo

Published by vzaidman over 5 years ago

Make sure to add whyDidYouRender on the component after wrapping it with React.memo and not before.

const ReactMemoTestComponent = React.memo(() => (
  <div>hi!</div>
))
ReactMemoTestComponent.whyDidYouRender = true
ReactMemoTestComponent.dispalyName = 'ReactMemoTestComponent'
why-did-you-render - Functional components tracking fix

Published by vzaidman over 5 years ago

We were tracking functional components props updates across all instances of it: https://github.com/welldone-software/why-did-you-render/issues/7.

This got fixed by saving prevProps on the component's ref.

why-did-you-render - Support extension of untranspiled classes

Published by vzaidman over 5 years ago

The bug https://github.com/welldone-software/why-did-you-render/issues/5, where people got Class constructors must be invoked with 'new' was identified as caused by extension of native "class" object types.

We added the targets:

  "main-no-classes-transpile": "dist/no-classes-transpile/cjs/whyDidYouRender.min.js",
  "module-no-classes-transpile": "dist/no-classes-transpile/esm/whyDidYouRender.min.js",
  "browser-no-classes-transpile": "dist/no-classes-transpile/umd/whyDidYouRender.min.js"

and now imports similar to

  const whyDidYouRender = require('@welldone-software/why-did-you-render/dist/no-classes-transpile/umd/whyDidYouRender.min.js');

where classes are used without transpilation.

Also, upgraded all packages to their latest version, including rollup v1.1.0.

why-did-you-render - Support React.createFactory

Published by vzaidman almost 6 years ago

  • Updated all packages on development.
  • Added tests and demos of React.cloneElement and React.createFactory.
  • We found out React.createFactory skipped the monkey patch we apply on React.createElement thus the following code didn't work:
import {lifecycle} from 'recompose';

const PostsList = ({ posts }) => (
  <ul>{posts.map(p => <li>{p.title}</li>)}</ul>
);

const PostsListWithData = lifecycle({
  componentDidMount() {
    fetchPosts().then(posts => {
      this.setState({ posts });
    })
  }
})(PostsList);
PostsList.whyDidYouRender = true;

because lifecycle uses React.createFactory to create it's child which is PostsList in this case:
https://github.com/acdlite/recompose/blob/master/src/packages/recompose/lifecycle.js