@phenomenon-hooks/use-why-did-you-update
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

useWhyDidYouUpdate


Installation

yarn add @phenomenon-hooks/use-why-did-you-update

or

npm i @phenomenon-hooks/use-why-did-you-update

Usage

import React from 'react';
import { useWhyDidYouUpdate } from '@phenomenon-hooks/use-why-did-you-update';

const Component: React.FC = () => {
    const [count, setCount] = React.useState(0);
    useWhyDidYouUpdate('Component', { count });

    return (
        <div>
            <p>Count: {count}</p>
            <button
                onClick={() => {
                    setCount(count + 1);
                }}
            >
                Increment
            </button>
        </div>
    );
};

Anatomy

useWhyDidYouUpdate('some-name', props);

Arguments

Argument Type Description
some-name string Name of the component. Will be displayed in the console.
props Record<string, any> Object with props that will be displayed in the console when component rerenders

Readme

Keywords

none

Package Sidebar

Install

npm i @phenomenon-hooks/use-why-did-you-update

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

10.8 kB

Total Files

8

Last publish

Collaborators

  • mykola.kolomoyets