next.js icon indicating copy to clipboard operation
next.js copied to clipboard

reportWebVitals seems to disable fast refresh in some cases

Open chrisdrackett opened this issue 4 years ago • 3 comments

Bug report

Describe the bug

I'm still working through this and have yet to reproduce in a small example. In our app if you add

export function reportWebVitals(metric) {
  console.log(metric)
}

to _app.tsx fast refresh will no longer work for some components. Take the above out and it appears to work for everything.

chrisdrackett avatar May 15 '20 03:05 chrisdrackett

Happy to take a look if you provide a demo!

Timer avatar May 15 '20 03:05 Timer

ok, was able to recreate this on a small scale. I wonder if this is related to our other issues.

in this branch: https://github.com/chrisdrackett/next-external-test/tree/broken

if you comment out the code here: https://github.com/chrisdrackett/next-external-test/blob/broken/web/pages/_app.tsx#L7

fast refresh will work (when editing https://github.com/chrisdrackett/next-external-test/blob/broken/external/src/Wrapper.tsx), if you leave it in editing the same file will result in a full refresh

chrisdrackett avatar May 15 '20 03:05 chrisdrackett

I'm experiencing this issue. In nextjs v12, if I edit _app.tsx, my fast refresh wasn't working but for other pages, it was working. As I don't edit _app.tsx much so I had no issue. But after upgrading to nextjs v13, any page I edit, it's performing a full refresh. I was confused about why it was happening. At first, I thought it might be due to I was using both /app and /pages dir but later I checked all my pages to make sure I'm not exporting any fs along with jsx element and found that only _app.tsx exports reportWebVitals function. I removed it and everything is working fine.

imranbarbhuiya avatar Nov 02 '22 03:11 imranbarbhuiya

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

github-actions[bot] avatar Nov 23 '23 00:11 github-actions[bot]