Skip to content

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

Open

Description

@dungle-scrubs

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

Activity

  1. qfdk commented on Jun 30, 2022

    @qfdk

    @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;
  2. dungle-scrubs commented on Jul 5, 2022

    @dungle-scrubs
    Author

    @qfdk Thank you, that helped.

  3. apperside commented on Dec 12, 2022

    @apperside

    For me it didn't worked untlll I added

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

    to tsconfig.ts

  4. mikechabot commented on Jan 9, 2023

    @mikechabot

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions