Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning and use of this file "reportWebVitals.js" in a react app? [duplicate]

Out of curiosity and finding ways to understand how reactjs works. I want to know the use of this file in a react boilerplate app. I am new to react.

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;

1 Answers

With the reportWebVitals function, you can send any of the results to an analytics endpoint to measure and track real user performance on your site.

For more information and examples visit the documentation here.

like image 67
Wahidullah Shadab Avatar answered Oct 29 '25 19:10

Wahidullah Shadab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!