welldone-software / 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.)
https://www.npmjs.com/package/@welldone-software/why-did-you-render
MIT License
11.11k stars 196 forks source link

WhyDidYouRender is not working in Storybook.js #290

Open syntaxerron opened 7 months ago

syntaxerron commented 7 months ago

Issue Summary

WhyDidYouRender is not working as expected in Storybook.js.

Environment Information

Description

I have followed the documentation to integrate WhyDidYouRender (WDYR), but it doesn't seem to be working if I have Storybook.js in my React application. I expected to see logs or indications of re-renders, but nothing is showing up in the console.

Steps to Reproduce

  1. Added the wdyr.js configuration file to the .storybook directory: // .storybook/wdyr.js

    import React from 'react';
    
    const whyDidYouRender = require('@welldone-software/why-did-you-render');
    whyDidYouRender(React, {
      trackAllPureComponents: true,
      trackHooks: true,
    });
  2. Imported wdyr.js in the preview.js file: // .storybook/preview.js
    import './wdyr';

Expected Behavior

I expected to see console logs indicating which components re-rendered and why, as specified in the WDYR configuration.

Actual Behavior

No logs or indications of re-renders are showing up in the console.