From 58c47725b9f2c171065b9e35cdbc0e4525ec7255 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 13 Mar 2021 21:40:29 +0300 Subject: Initialize project using Create React App --- src/reportWebVitals.ts | 15 +++++++++++++++ 1 file changed, 15 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..49a2a16 --- /dev/null +++ b/src/reportWebVitals.ts @@ -0,0 +1,15 @@ +import { ReportHandler } from 'web-vitals'; + +const reportWebVitals = (onPerfEntry?: ReportHandler) => { + if (onPerfEntry && onPerfEntry instanceof Function) { + 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