Skip to content

Commit

Permalink
fix(web): New reportWebVitals
Browse files Browse the repository at this point in the history
No clue why we need this in the first place
https://stackoverflow.com/a/78898219
  • Loading branch information
fliiiix committed Oct 11, 2024
1 parent 6681ca1 commit 7afafb2
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions web/src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { type ReportHandler } from 'web-vitals'
import { ReportCallback } from "web-vitals";

const reportWebVitals = (onPerfEntry?: ReportHandler): void => {
if (onPerfEntry == null || !(onPerfEntry instanceof Function)) {
return
const reportWebVitals = (onPerfEntry?: ReportCallback) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import("web-vitals").then(({ onCLS, onINP, onFCP, onLCP, onTTFB }) => {
onCLS(onPerfEntry);
onINP(onPerfEntry);
onFCP(onPerfEntry);
onLCP(onPerfEntry);
onTTFB(onPerfEntry);
});
}
};

void import('web-vitals').then(
({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry)
getFID(onPerfEntry)
getFCP(onPerfEntry)
getLCP(onPerfEntry)
getTTFB(onPerfEntry)
}
)
}

export default reportWebVitals
export default reportWebVitals;

0 comments on commit 7afafb2

Please sign in to comment.