Skip to content

Commit

Permalink
build: Fix reportWebVitals to use MetricType type
Browse files Browse the repository at this point in the history
  • Loading branch information
yutakusuno committed May 22, 2024
1 parent c01cef8 commit 04cc148
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { ReportHandler } from 'web-vitals';
// https://github.com/GoogleChrome/web-vitals/pull/483

const reportWebVitals = (onPerfEntry?: ReportHandler) => {
import { MetricType } from 'web-vitals';

const reportWebVitals = (onPerfEntry?: (metric: MetricType) => void) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
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 04cc148

Please sign in to comment.