Skip to content

Commit 3623270

Browse files
DangDang
authored andcommitted
Fix build issues and web-vitals import
- Fixed web-vitals import to use correct API (onCLS, onFID, etc.) - Fixed ESLint import order issue in App.js - Temporarily switched to react-scripts build for compatibility - Build now successful with proper code splitting
1 parent ede0f7a commit 3623270

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

VehicleShowroom/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
"web-vitals": "^4.2.2"
4242
},
4343
"scripts": {
44-
"start": "craco start",
45-
"build": "craco build",
46-
"test": "craco test",
47-
"test:ci": "craco test --coverage --watchAll=false --passWithNoTests",
44+
"start": "react-scripts start",
45+
"build": "react-scripts build",
46+
"test": "react-scripts test",
47+
"test:ci": "react-scripts test --coverage --watchAll=false --passWithNoTests",
4848
"lint": "eslint src --ext .js,.jsx --max-warnings 0",
4949
"lint:fix": "eslint src --ext .js,.jsx --fix",
5050
"eject": "react-scripts eject",
@@ -74,11 +74,11 @@
7474
]
7575
},
7676
"devDependencies": {
77+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
78+
"@craco/craco": "^7.1.0",
7779
"anymatch": "^3.1.3",
7880
"chokidar": "^3.6.0",
7981
"gh-pages": "^6.1.1",
80-
"micromatch": "^4.0.7",
81-
"@craco/craco": "^7.1.0",
82-
"@babel/plugin-syntax-dynamic-import": "^7.8.3"
82+
"micromatch": "^4.0.7"
8383
}
8484
}

VehicleShowroom/src/App.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ import { useState, Suspense, lazy } from 'react';
55

66
import initialTheme from './theme/theme';
77
import useWebVitals from './hooks/useWebVitals';
8+
import { UserProvider } from 'contexts/UserContext';
89

910
// 🧩 Layouts - Lazy loaded for better performance
1011
const AuthLayout = lazy(() => import('./layouts/auth'));
1112
const AdminLayout = lazy(() => import('./layouts/admin'));
1213
const UserLayout = lazy(() => import('layouts/user'));
1314

14-
// 🧩 Providers
15-
import { UserProvider } from 'contexts/UserContext';
16-
1715
// Loading component
1816
const LoadingSpinner = () => (
1917
<div style={{

VehicleShowroom/src/hooks/useWebVitals.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react';
2-
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';
2+
import { onCLS, onFID, onFCP, onLCP, onTTFB } from 'web-vitals';
33

44
function reportWebVitals(metric) {
55
console.log(metric);
@@ -18,11 +18,11 @@ function reportWebVitals(metric) {
1818

1919
export function useWebVitals() {
2020
useEffect(() => {
21-
getCLS(reportWebVitals);
22-
getFID(reportWebVitals);
23-
getFCP(reportWebVitals);
24-
getLCP(reportWebVitals);
25-
getTTFB(reportWebVitals);
21+
onCLS(reportWebVitals);
22+
onFID(reportWebVitals);
23+
onFCP(reportWebVitals);
24+
onLCP(reportWebVitals);
25+
onTTFB(reportWebVitals);
2626
}, []);
2727
}
2828

0 commit comments

Comments
 (0)