A Welldone Software library that patches React in development to log potentially unnecessary component re-renders. It also supports React Native workflows when wired through Babel and a first-import setup file.
Overview
Why Did You Render hooks into React during development and reports when components re-render in ways that might be avoidable. A common pattern it highlights is passing freshly created objects—such as inline style objects—to memoized children, which forces updates even when values look the same.
You enable it by importing a small setup module before the rest of the application, configuring Babel for automatic JSX where required, and choosing which components to watch. You can opt into tracking all pure components, mark individual components manually, filter by display name, and tune console output colors, grouping, and custom notifiers.
Hook usage is supported by default, and you can extend tracking to custom hooks such as Redux selectors through extra hook registration. Options cover owner re-render reasons, logging on legitimate prop or state changes, hot-reload buffering, and include or exclude rules.
It is intended for development only: the authors warn that it slows React noticeably, monkey-patches internals, and may behave unexpectedly in production. They also note incompatibility concerns with React Compiler and that not every re-render is worth fixing without measuring with React DevTools Profiler.
Key features
- Monkey-patches React for re-render notifications
- Tracks memo and PureComponent re-renders
- Per-component manual tracking flag
- Hook change tracking with extra hooks
- Include and exclude filters by display name
- Custom console notifier and styling
- Owner re-render reason logging
- React Native Babel plugin support
Use cases
- Finding avoidable React re-renders in development
- Debugging why a specific component updates
- Tracing custom hook-driven updates
- Tuning memoized component props
- React Native performance investigation