From f2ecc1803f3ea294a0c6b7915b61348ed0395b26 Mon Sep 17 00:00:00 2001 From: Marcin Zelent Date: Wed, 16 Nov 2022 15:16:38 +0100 Subject: Remade and extended the app using React --- src/reportWebVitals.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/reportWebVitals.ts (limited to 'src/reportWebVitals.ts') diff --git a/src/reportWebVitals.ts b/src/reportWebVitals.ts new file mode 100644 index 0000000..73d7c3e --- /dev/null +++ b/src/reportWebVitals.ts @@ -0,0 +1,17 @@ +import { ReportHandler } from 'web-vitals'; + +type FuncType = (onPerfEntry?: ReportHandler) => void; + +const reportWebVitals: FuncType = (onPerfEntry?: ReportHandler) => { + if (onPerfEntry !== null && onPerfEntry instanceof Function) { + void import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + getCLS(onPerfEntry); + getFID(onPerfEntry); + getFCP(onPerfEntry); + getLCP(onPerfEntry); + getTTFB(onPerfEntry); + }); + } +}; + +export default reportWebVitals; -- cgit v1.2.3