1.0.3 • Published 7 months ago

use-why-did-you-render v1.0.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

useWhyDidYouRender

This react hook helps to find which prop change is causing re-renders in a React component, making it easier to fix rendering issues in the React component.

How to use it:

  1. First, install.

  npm install use-why-did-you-render
            OR
  yarn add use-why-did-you-render
  1. Then,add the below code to your component.
useWhyDidYouRender(props, { name : "COMPONENT_NAME", printLog: true });
            OR
const { changedProps } = useWhyDidYouRender(props);
console.log(changedProps);
  1. When component re-renders, it will print it on console.
COMPONENT_NAME => {
    PROP_NAME: {
        from: oldValue,
        to: newValue,
    },
    PROP_NAME_2: {
        from: oldValue,
        to: newValue,
    },
}

Options

PropertyDescriptionTypeDefault
nameLike Component namestringuseWhyDidYouRender
printLogIf true prints prop changesbooleanfalse

License

MIT © pulkitchdha

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago