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

Can you provide a Next.js v12 example? #239

Open
dungle-scrubs opened this issue Apr 4, 2022 · 4 comments
Open

Can you provide a Next.js v12 example? #239

dungle-scrubs opened this issue Apr 4, 2022 · 4 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dungle-scrubs
Copy link

I've been trying to get it to work with Next.js v11 and now v12 but have never had any success. Would you mind providing an example?

Thanks

@vzaidman vzaidman added help wanted Extra attention is needed good first issue Good for newcomers labels Apr 18, 2022
@qfdk
Copy link

qfdk commented Jun 30, 2022

@dungle-scrubs Hello, i use next v12.

You need the steps as follows :

1. Create a wdyr.js

import React from 'react';
if (process.env.NODE_ENV === 'development') {
    const whyDidYouRender = require('@welldone-software/why-did-you-render');
    whyDidYouRender(React, {
        trackAllPureComponents: true,
        onlyLogs: true,
        titleColor: "green",
    });
}

2. Import the wdyr.js in _app.js

import '../hooks/wdyr';

3. Add props in the compostant

const XXX=()=>{
    return <h1>xxx</h1>
}
XXX.whyDidYouRender = true;
export default XXX;

@dungle-scrubs
Copy link
Author

@qfdk Thank you, that helped.

@apperside
Copy link

For me it didn't worked untlll I added

"jsxImportSource": "@welldone-software/why-did-you-render"

to tsconfig.ts

@mikechabot
Copy link

@apperside Thanks. Can confirm this was also the solution to allow wdyr logging for Next 13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants