Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wdyr not work in next13 (repo provided) #272

Open
15077693d opened this issue May 26, 2023 · 2 comments
Open

wdyr not work in next13 (repo provided) #272

15077693d opened this issue May 26, 2023 · 2 comments

Comments

@15077693d
Copy link

15077693d commented May 26, 2023

Repo for details: 15077693d/Next-js-Boilerplate-adding-why-did-you-render@19ea9f0
I followed implementation from vercel/next.js/tree/canary/examples/with-why-did-you-render

Result(No log in console):

Screen.Recording.2023-05-26.at.1.20.25.PM.mov
@jens-duttke
Copy link

There are two things which need to get changed in your code:

  1. As you expect a logging for changed values, if you click on the button in the Header, you need to set the logOnDifferentValues option of whyDidYouRender to true.

  2. There seems to be a bug in

    return !!(
    Component.whyDidYouRender || (
    wdyrStore.options.trackAllPureComponents && (
    (Component && Component.prototype instanceof wdyrStore.React.PureComponent) ||
    isMemoComponent(Component)
    )
    ) ||
    shouldInclude(displayName)
    );

    But there is a workaround for it, by setting include to [/./].

So to fix that both, your scripts/wdyr.ts should contain:

whyDidYouRender(React, {
  trackAllPureComponents: true,
  logOnDifferentValues: true,
  include: [/./],
});

@scamden
Copy link

scamden commented Oct 25, 2023

thanks for the workaround! would be great t fix this for real as it was very confusing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants