Skip to content

Commit

Permalink
updated web-vitals package (#2253)
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavChuiko committed Oct 8, 2024
1 parent c356a94 commit a813500
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"simplebar-react": "^3.2.4",
"socket.io-client": "^4.7.5",
"vite-plugin-svgr": "^4.1.0",
"web-vitals": "^3.5.0"
"web-vitals": "^4.2.2"
},
"devDependencies": {
"@babel/core": "^7.23.2",
Expand Down
20 changes: 9 additions & 11 deletions src/plugins/report-web-vitals.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { ReportHandler } from 'web-vitals'
import { MetricType } from 'web-vitals'

const reportWebVitals = (onPerfEntry: ReportHandler): void => {
const reportWebVitals = (onPerfEntry?: (metric: MetricType) => void): void => {
if (onPerfEntry && typeof onPerfEntry === 'function') {
void import('web-vitals').then(
({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry)
getFID(onPerfEntry)
getFCP(onPerfEntry)
getLCP(onPerfEntry)
getTTFB(onPerfEntry)
}
)
void import('web-vitals').then(({ onCLS, onINP, onFCP, onLCP, onTTFB }) => {
onCLS(onPerfEntry)
onINP(onPerfEntry)
onFCP(onPerfEntry)
onLCP(onPerfEntry)
onTTFB(onPerfEntry)
})
}
}

Expand Down

0 comments on commit a813500

Please sign in to comment.