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.12k stars 199 forks source link

How to interpret call stacks when all components are now named `WDYRFunctionalComponent` or `WDYRPatchedClassComponent` ? #211

Closed justingrant closed 2 years ago

justingrant commented 3 years ago

When React displays a call stack in the debug console that includes components patched by WDYR, there's no way to know which component caused the problem. Any idea how to discover which actual component is causing the problem, other than disabling WDYR and running the debug session again?

Here's an example call stack I just got:

Warning: `value` prop on `input` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.
    at input
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at div
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at form
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at Route (https://localhost:3000/static/js/vendors~main.chunk.js:204936:29)
    at WDYRPatchedClassComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49914:9)
    at Routes
    at div
    at div
    at div
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at Router (https://localhost:3000/static/js/vendors~main.chunk.js:204567:30)
    at BrowserRouter (https://localhost:3000/static/js/vendors~main.chunk.js:204101:35)
    at div
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
    at WDYRFunctionalComponent (https://localhost:3000/static/js/vendors~main.chunk.js:49999:33)
vzaidman commented 2 years ago

The actual components save their DisplayName. For example: https://codesandbox.io/s/why-did-you-render-sandbox-forked-9ziy0

Screenshot 2021-11-14 at 16 58 25

It looks like the problem might be with one specific component that WDYR uses to wrap your own component. I'd investigate this specific issue a little further.

Also is it possible WDYR is used on an "input" component somehow?