Skip to content

Commit

Permalink
Upgraded libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola-iacovelli committed Oct 7, 2024
1 parent 48db6e1 commit 3a2cf2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
8 changes: 5 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './page/App';
import reportWebVitals from './reportWebVitals';
import {BrowserRouter} from "react-router-dom";
import {Provider} from "react-redux";
import {eventReducer} from "./reducer/Reducer";
import {configureStore} from "@reduxjs/toolkit";
import {AnalyticsComponent} from './component/AnalyticsComponent';
import {onCLS, onINP, onLCP} from 'web-vitals';
import {sendToAnalytics} from "./utils/analyticsUtils";
import React from 'react';
import {sendToAnalytics} from './utils/analyticsUtils';


const root = ReactDOM.createRoot(
Expand All @@ -35,4 +35,6 @@ 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(sendToAnalytics);
onCLS(sendToAnalytics);
onINP(sendToAnalytics);
onLCP(sendToAnalytics);
4 changes: 2 additions & 2 deletions src/reducer/Reducer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
Action,
ADD_TO_SHOPPING_LIST_TYPE,
CLEAR_ERROR_TYPE,
CLEAR_SHOPPING_LIST_TYPE,
CLEAR_USER_TYPE,
CustomAction,
REMOVE_FROM_SHOPPING_LIST_TYPE,
SET_CURRENT_FOOD_CONSUMPTION_TYPE,
SET_CURRENT_ITEM_TYPE,
Expand Down Expand Up @@ -55,7 +55,7 @@ export const initialState: GroceryState = {
isUserPersisted: false,
}

export function eventReducer(state: GroceryState = initialState, action: Action): GroceryState {
export function eventReducer(state: GroceryState = initialState, action: CustomAction): GroceryState {
switch (action.type) {
case SET_CURRENT_ITEM_TYPE:
return {
Expand Down
19 changes: 5 additions & 14 deletions src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { ReportHandler } from 'web-vitals';
import {onCLS, onINP, onLCP} from 'web-vitals';
import {sendToAnalytics} from "./utils/analyticsUtils";

const reportWebVitals = (onPerfEntry?: ReportHandler) => {
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;
onCLS(sendToAnalytics);
onINP(sendToAnalytics);
onLCP(sendToAnalytics);

0 comments on commit 3a2cf2e

Please sign in to comment.