Skip to content

web-vital.js compatibility issue <with solution> #13723

Open
@rjosh003-CS

Description

@rjosh003-CS

step 1: Run

npm install web-vitals@latest

I found the web-vitals have changed its export variables; resulting in a web-vital.js crash with the latest updates.

Step 2: change the file "reportWebVitals"

// reportWebVitals.ts
import { onCLS, onFCP, onLCP, onTTFB } from 'web-vitals';

const reportWebVitals = (onPerfEntry?: (metric: any) => void) => {
  if (onPerfEntry && typeof onPerfEntry === 'function') {
    onCLS(onPerfEntry);
    onFCP(onPerfEntry);
    onLCP(onPerfEntry);
    onTTFB(onPerfEntry);
  }
};

export default reportWebVitals;

The code above would resolve the web-vitals issues with the latest update.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions