feat(UI): web-vitals is added (#422)

This commit is contained in:
pal-sig 2021-12-02 18:36:30 +05:30 committed by GitHub
parent 5e4cff7ae2
commit 9bc62d83d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -5,8 +5,13 @@ import AppRoutes from 'AppRoutes';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import reportWebVitals from 'reportWebVitals';
import store from 'store';
if (process.env.NODE_ENV === 'development') {
reportWebVitals(console.log);
}
ReactDOM.render(
<Provider store={store}>
<React.StrictMode>

View File

@ -0,0 +1,15 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler): void => {
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;