Unverified Commit 8c242ac0 authored by Jimmy Chion's avatar Jimmy Chion Committed by GitHub

[docs] update analytics doc to use `useReportWebVitals` (again) (#62654)

Closes #62653

Finishes the job started by https://github.com/vercel/next.js/pull/58196
and updates the last remaining code example that uses `reportWebVitals`
to use `useReportWebVitals`
Co-authored-by: 's avatarSam Ko <sam@vercel.com>
parent 6a7a0da7
...@@ -164,21 +164,27 @@ measure the time it takes for the page to hydrate and render: ...@@ -164,21 +164,27 @@ measure the time it takes for the page to hydrate and render:
You can handle all the results of these metrics separately: You can handle all the results of these metrics separately:
```js ```jsx filename="pages/_app.js"
export function reportWebVitals(metric) { import { useReportWebVitals } from 'next/web-vitals'
switch (metric.name) {
case 'Next.js-hydration': function MyApp({ Component, pageProps }) {
// handle hydration results useReportWebVitals((metric) => {
break switch (metric.name) {
case 'Next.js-route-change-to-render': case 'Next.js-hydration':
// handle route-change to render results // handle hydration results
break break
case 'Next.js-render': case 'Next.js-route-change-to-render':
// handle render results // handle route-change to render results
break break
default: case 'Next.js-render':
break // handle render results
} break
default:
break
}
})
return <Component {...pageProps} />
} }
``` ```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment