Reputation: 3586
The React doc on Profiler says the following:
Pitfall
Profiling adds some additional overhead, so it is disabled in the production build by default. To opt into production profiling, you need to enable a special production build with profiling enabled.
In that Gist, there are comments like these:
which says:
In Vite putting this in
vite.config.ts
worked:
export default defineConfig({
// ...
resolve: {
alias: {
'react-dom': path.resolve(
__dirname,
'node_modules/react-dom/profiling'
),
'scheduler/tracing': path.resolve(
__dirname,
'node_modules/scheduler/tracing-profiling'
),
},
},
// ...
which says:
{
resolve: {
alias: [
{ find: /^react-dom$/, replacement: 'react-dom/profiling' },
{ find: 'scheduler/tracing', replacement: 'scheduler/tracing-profiling' }
]
}
}
in
vite.config.js
did the trick for me.
My question is: is any of these comments the recommended guidance, or is there another way of doing it?
Upvotes: 2
Views: 208
Reputation: 12555
Just using a simple alias worked for me:
export default defineConfig({
// ...
resolve: {
alias: {
'react-dom/client': 'react-dom/profiling'
}
}
And include the <Profiler>
component around the app-
See this answer as well - https://stackoverflow.com/a/76647767/228369
Upvotes: 0