From 6c31c1c1f9fdfeb5145c0dbf5a39d925511ad1ec Mon Sep 17 00:00:00 2001 From: Juan Diaz Date: Fri, 27 Oct 2023 12:23:24 -0400 Subject: [PATCH] [add] reportWebVitals got add it back to the project since I delete them by mistake at the begining of the project due to lack of knowledge --- src/index.js | 6 ++++++ src/reportWebVitals.js | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/reportWebVitals.js diff --git a/src/index.js b/src/index.js index 31508db..770ee7d 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ import React from "react"; import ReactDOM from "react-dom/client"; import "./index.css"; import App from "./App"; +import reportWebVitals from "./reportWebVitals"; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( @@ -9,3 +10,8 @@ root.render( ); + +// If you want to start measuring performance in your app, pass a function +// to log results (for example: reportWebVitals(console.log)) +// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals +reportWebVitals(); diff --git a/src/reportWebVitals.js b/src/reportWebVitals.js new file mode 100644 index 0000000..5253d3a --- /dev/null +++ b/src/reportWebVitals.js @@ -0,0 +1,13 @@ +const reportWebVitals = onPerfEntry => { + 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;