-
Notifications
You must be signed in to change notification settings - Fork 199
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
Integration with Next.js 13 app folder? #266
Comments
Closed
This works for me:
const path = require('path');
/** @typedef {Parameters<import('next').NextConfig['webpack']>[1]} WebpackConfigContext */
const injectionSource = path.join(__dirname, 'injection.ts');
/**
* @param {import('webpack').Configuration} config
* @param {WebpackConfigContext} context
*/
module.exports = (config, context) => {
if (context.dev && !context.isServer) {
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (entries['main-app'] && !entries['main-app'].includes(injectionSource)) {
entries['main-app'].unshift(injectionSource);
}
return entries;
};
}
}; Here, instead of
import React from 'react';
import whyDidYouRender from '@welldone-software/why-did-you-render';
// eslint-disable-next-line no-console -- Show information that `whyDidYouRender` has been applied to the website.
console.debug('Applying whyDidYouRender, to help you locate unnecessary re-renders during development. See https://github.com/welldone-software/why-did-you-render');
// See https://github.com/welldone-software/why-did-you-render#options
whyDidYouRender(React, {
trackAllPureComponents: true,
trackHooks: true,
logOwnerReasons: true,
collapseGroups: true,
include: [/./],
// This is for testing, remove it, if you don't want to log on different values
logOnDifferentValues: true
}); In your const injectWhyDidYouRender = require('./scripts/why-did-you-render');
/** @type {import('next').NextConfig} */
module.exports = {
...
webpack: (config, context) => {
injectWhyDidYouRender(config, context)
return config;
}
}; The why-did-you-render/src/shouldTrack.js Lines 39 to 47 in 0f364e8
|
mariogiampieri
added a commit
to districtr/districtr-v2
that referenced
this issue
Sep 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to this comment the community still don't have a working example of how to integrate with Next.js 13.
I can see the official repository from vercel has an example using the
pages
folder but still no example with theapp
folder?Perhaps the Next.js 13 example would be based off the beta documentation example for client side providers: Rendering third-party context providers in Server Components ?
The text was updated successfully, but these errors were encountered: