# use-why-render-plus

> A React hook for quickly understanding why a component re-rendered via pretty console output

Latest version **1.0.2** (published 2023-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-why-render-plus
pnpm add use-why-render-plus
yarn add use-why-render-plus
bun add use-why-render-plus
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-05-29 |
| First published | 2023-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 50.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Eric Whitefield |
| Maintainers | ericwhitefield |

## Links

- npm: https://www.npmjs.com/package/use-why-render-plus
- Repository: https://github.com/ericwhitefield/use-why-render-plus
- Homepage: https://github.com/ericwhitefield/use-why-render-plus#readme
- Issues: https://github.com/ericwhitefield/use-why-render-plus/issues
- npm.io page: https://npm.io/package/use-why-render-plus

## Recent versions

- 1.0.2 (latest) — 2023-05-29
- 1.0.1 — 2023-05-24
- 1.0.0 — 2023-05-23

## README

# use-why-render-plus

## Quickly view all the reasons your React hook component (re)rendered

A zero-config hook with pretty console output.

Drop in a single line of code with this hook to view component render count, reason, and prop values.

Spot re-renders vs new renders from zero.

### Example usage

```tsx
export default function MyComponent({
  init,
  text,
  count,
}: {
  init: string;
  text?: string;
  count?: number;
}) {
  const [name, setName] = useState(init);

  useWhyRenderPlus("MyComponent", {
    name,
    text,
    count,
  });

  return <h1>MyComponent</h1>;
}
```

### Example output

![example console output](https://github.com/ericwhitefield/use-why-render-plus/blob/main/images/exmaple.png?raw=true)

### Options

Configure the output how you like. For exmaple, highlight only value changes, or put full state output on each re-render.

```tsx
const optionsDefault: OPTIONS = {
  on_change: true, // print the param name when it changes
  on_same: false, // print the param name even when it has not changed
  val_previous: false, // include previous value on print
  val_current: false, // include current value on print
  color_header: "#ad04db",
  color_params: "#e205ff",
  logger: console.log,
};

export const useWhyRenderPlus = (
  label: string,
  deps?: Record<string, any>,
  options: Partial<OPTIONS> = optionsDefault
): void => {};
```

---
_Source: https://npm.io/package/use-why-render-plus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
