refactor: remove unused imports and optimize dependencies in multiple components

This commit is contained in:
Naveen Kumar 2025-04-22 02:26:13 +05:30
parent 03fb97f357
commit b0fdc16d49
10 changed files with 24 additions and 25 deletions

View File

@ -1,5 +1,3 @@
import { useState, useEffect } from "react";
export default function Translate() {
return (
<div className="flex justify-between items-center bg-gray-800 text-white px-2 mx-auto">

View File

@ -1,4 +1,3 @@
import { useState } from "react";
import Header from "./Header";
import Faq from "./Faq";
import Footer from "./Footer";

View File

@ -141,7 +141,7 @@ const GameList = () => {
setCurrentTime(formattedTime);
return () => clearInterval(interval);
}, []);
}, [API_URL]);
// Show chart for selected team
const handleViewChart = async (team) => {

View File

@ -106,7 +106,7 @@ const Home = () => {
setCurrentTime(formattedTime);
return () => clearInterval(interval);
}, []);
}, [API_URL]);
// Show chart for selected team
const handleViewChart = async (team) => {
@ -263,7 +263,7 @@ const Home = () => {
{/* Contact Link */}
<p className="mt-2 text-green-600 font-medium bg-white p-1 w-full lg:w-3/4 m-auto">
हमस पर करन ि <a href="#" className="underline">यह ि कर</a>
हमस पर करन ि <a href="#" role="button" className="btn">Click Here</a>
</p>
{/* Timestamp */}
@ -473,4 +473,6 @@ const Home = () => {
);
};
export default Home;
export default Home;
const result = (condition1 && condition2) || (condition3 && condition4);

View File

@ -140,7 +140,7 @@ const Home2 = () => {
setCurrentTime(formattedTime);
return () => clearInterval(interval);
}, []);
}, [API_URL]);
// Show chart for selected team
const handleViewChart = async (team) => {

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useMemo } from 'react';
import { RefreshCw, Clock, ChevronDown, ChevronUp, Calendar, AlertTriangle } from 'lucide-react';
const MatkaResultsDashboard = () => {
@ -9,7 +9,7 @@ const MatkaResultsDashboard = () => {
const [expandedTeams, setExpandedTeams] = useState({});
// Matka teams and their scheduled times
const matkaTeams = [
const matkaTeams = useMemo(() => [
{
team: "Desawar Matka",
time: "5:00 AM",
@ -46,7 +46,7 @@ const MatkaResultsDashboard = () => {
description: "End your day with the Gali Matka results at 11:30 PM. Our platform offers live updates, daily charts, and expert tips to help you make informed decisions.",
tip: "Use the Gali Matka chart to track historical results and improve your guessing accuracy."
}
];
], []);
// Format time
const formatTime = (timeString) => {
@ -123,7 +123,7 @@ const MatkaResultsDashboard = () => {
};
generateMockResults();
}, []);
}, [matkaTeams]);
// Refresh data
const handleRefresh = () => {

View File

@ -1,7 +1,7 @@
import { useState } from "react";
const TeamMatchTable = () => {
const [teams, setTeams] = useState([
const [teams] = useState([
{ name: "GALI MATKA", time: "11:30 PM" },
{ name: "GHAZIABAD MATKA", time: "9:30 PM" },
{ name: "FARIDABAD MATKA", time: "6:00 PM" },

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useCallback } from 'react';
import { RefreshCw, Clock, ChevronDown, ChevronUp, Calendar, AlertTriangle } from 'lucide-react';
import axios from 'axios';
@ -62,7 +62,7 @@ const MatkaResultsDashboard = () => {
}));
};
const fetchTodaysResults = async () => {
const fetchTodaysResults = useCallback(async () => {
try {
setLoading(true);
setError(null);
@ -117,11 +117,11 @@ const MatkaResultsDashboard = () => {
setError("Failed to load today's Matka data. Please try again later.");
setLoading(false);
}
};
}, []);
useEffect(() => {
fetchTodaysResults();
}, []);
}, [fetchTodaysResults]);
const handleRefresh = () => {
fetchTodaysResults();

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useCallback } from 'react';
import { RefreshCw, Clock } from 'lucide-react';
import axios from 'axios';
import TeamMatchTable from './Teams';
@ -25,7 +25,7 @@ const TodaysMatch = () => {
};
// Fetch matches
const fetchMatches = async () => {
const fetchMatches = useCallback(async () => {
try {
setLoading(true);
@ -68,12 +68,12 @@ const TodaysMatch = () => {
setError("Failed to load match data. Please try again later.");
setLoading(false);
}
};
}, []);
// On component mount
useEffect(() => {
fetchMatches();
}, []);
}, [fetchMatches]);
// Refresh handler
const handleRefresh = () => {

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useMemo } from 'react';
import { RefreshCw, Clock, ChevronDown, ChevronUp, Calendar, AlertTriangle } from 'lucide-react';
import axios from 'axios';
@ -14,7 +14,7 @@ const MatkaResultsDashboard = () => {
const API_URL = `http://${API_HOST}/api`;
// Matka team descriptions and tips
const matkaTeamInfo = {
const matkaTeamInfo = useMemo(() => ({
"Desawar Matka": {
description: "Start your day with the latest Desawar Matka results at 5:00 AM. Our platform provides real-time updates and accurate results to help you stay ahead.",
tip: "Analyze the Desawar Matka chart to identify patterns and trends for better predictions."
@ -39,7 +39,7 @@ const MatkaResultsDashboard = () => {
description: "End your day with the Gali Matka results at 11:30 PM. Our platform offers live updates, daily charts, and expert tips to help you make informed decisions.",
tip: "Use the Gali Matka chart to track historical results and improve your guessing accuracy."
}
};
}), []);
// Format time
const formatTime = (timeString) => {
@ -124,7 +124,7 @@ const MatkaResultsDashboard = () => {
};
fetchTodaysResults();
}, []);
}, [API_URL, matkaTeamInfo]);
// Refresh data
const handleRefresh = () => {