From b0fdc16d495fc334bde0aba4d0aee656f97c58b6 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Tue, 22 Apr 2025 02:26:13 +0530 Subject: [PATCH] refactor: remove unused imports and optimize dependencies in multiple components --- src/Translate.js | 2 -- src/pages/FaqPage.js | 1 - src/pages/GameList.js | 2 +- src/pages/Home.js | 8 +++++--- src/pages/Home2.js | 2 +- src/pages/Random.js | 8 ++++---- src/pages/Teams.js | 2 +- src/pages/Today.js | 8 ++++---- src/pages/TodaysMatch.js | 8 ++++---- src/pages/UserView.js | 8 ++++---- 10 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/Translate.js b/src/Translate.js index 261cbb2..f6c8533 100644 --- a/src/Translate.js +++ b/src/Translate.js @@ -1,5 +1,3 @@ -import { useState, useEffect } from "react"; - export default function Translate() { return (
diff --git a/src/pages/FaqPage.js b/src/pages/FaqPage.js index d21a570..4b8d454 100644 --- a/src/pages/FaqPage.js +++ b/src/pages/FaqPage.js @@ -1,4 +1,3 @@ -import { useState } from "react"; import Header from "./Header"; import Faq from "./Faq"; import Footer from "./Footer"; diff --git a/src/pages/GameList.js b/src/pages/GameList.js index 9776912..415f043 100644 --- a/src/pages/GameList.js +++ b/src/pages/GameList.js @@ -141,7 +141,7 @@ const GameList = () => { setCurrentTime(formattedTime); return () => clearInterval(interval); - }, []); + }, [API_URL]); // Show chart for selected team const handleViewChart = async (team) => { diff --git a/src/pages/Home.js b/src/pages/Home.js index 4a6d1b0..a36b373 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -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 */}

- हमसे संपर्क करने के लिए ➡ यहाँ क्लिक करें + हमसे संपर्क करने के लिए ➡ Click Here

{/* Timestamp */} @@ -473,4 +473,6 @@ const Home = () => { ); }; -export default Home; \ No newline at end of file +export default Home; + +const result = (condition1 && condition2) || (condition3 && condition4); \ No newline at end of file diff --git a/src/pages/Home2.js b/src/pages/Home2.js index 65f5ae6..1a56aa9 100644 --- a/src/pages/Home2.js +++ b/src/pages/Home2.js @@ -140,7 +140,7 @@ const Home2 = () => { setCurrentTime(formattedTime); return () => clearInterval(interval); - }, []); + }, [API_URL]); // Show chart for selected team const handleViewChart = async (team) => { diff --git a/src/pages/Random.js b/src/pages/Random.js index 6756156..223d020 100644 --- a/src/pages/Random.js +++ b/src/pages/Random.js @@ -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 = () => { diff --git a/src/pages/Teams.js b/src/pages/Teams.js index e0f1ae6..4bb679e 100644 --- a/src/pages/Teams.js +++ b/src/pages/Teams.js @@ -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" }, diff --git a/src/pages/Today.js b/src/pages/Today.js index 52af106..bfd6471 100644 --- a/src/pages/Today.js +++ b/src/pages/Today.js @@ -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(); diff --git a/src/pages/TodaysMatch.js b/src/pages/TodaysMatch.js index 59aae0a..133d19c 100644 --- a/src/pages/TodaysMatch.js +++ b/src/pages/TodaysMatch.js @@ -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 = () => { diff --git a/src/pages/UserView.js b/src/pages/UserView.js index 5505e3e..bda39e7 100644 --- a/src/pages/UserView.js +++ b/src/pages/UserView.js @@ -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 = () => {