why-did-you-render icon indicating copy to clipboard operation
why-did-you-render copied to clipboard

Cannot get WDYR output from nextjs dynamically loaded component (e.g. for no-ssr use case)

Open bram2000 opened this issue 2 years ago • 2 comments

Hello,

In Next.js (12) I'm using the dynamic import as recommended in the docs to prevent the component from breaking when server-side. Unfortunately I'm unable to get any output from WDYR for such components and my assumption is that it's related to the dynamic import (since it works fine in my other components which are imported as normal).

Is this a limitation of WDYR, or is there something I can do to get it working?

Thanks!

bram2000 avatar Jul 02 '23 12:07 bram2000

Having tried to create an example of this in code sandbox, it seems that the library does in fact work with dynamically loaded components (at least in the very simple case), so I'm not actually sure why I can only get output for certain components within my app.

bram2000 avatar Jul 04 '23 11:07 bram2000

This sounds similar to the problem I had, that why-did-you-render doesn't work with Next.js v13+ at all.

A workaround I found was to add include: [/./] to the why-did-you-render options, as described here: https://github.com/welldone-software/why-did-you-render/issues/272#issuecomment-1645114930

Maybe this works for you issue as well.

jens-duttke avatar Jul 21 '23 07:07 jens-duttke