Skip to content

Commit

Permalink
refacto: remove useless useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
baptou12 committed Oct 28, 2023
1 parent 076f667 commit be792c9
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions pages/institutions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react"
import { useState, useMemo } from "react"

Check failure on line 1 in pages/institutions.js

View workflow job for this annotation

GitHub Actions / lint-and-build

'useMemo' is defined but never used

import useFetchInstitutionsData from "../hooks/fetch-institutions-data"
import InfoIcon from "../components/InfoIcon"
Expand All @@ -14,6 +14,7 @@ const filterData = (
sortKey,
sortOrder,
) => {
console.log("filterData")
let filters = {}

if (queryName) {
Expand All @@ -39,30 +40,24 @@ const filterData = (

const InstitutionsStats = () => {
const { dataService, loading, error } = useFetchInstitutionsData()
const [results, setResults] = useState([])

const [queryName, setQueryName] = useState("")
const [queryCode, setQueryCode] = useState("")
const [selectedType, setSelectedType] = useState(allType)
const [sortKey, setSortKey] = useState(null)
const [sortOrder, setSortOrder] = useState(defaultSortOrder)

useEffect(() => {
if (!dataService) {
return
}

setResults(
filterData(
dataService,
queryName,
queryCode,
selectedType,
sortKey,
sortOrder,
),
let results = []
if (dataService) {
results = filterData(
dataService,
queryName,
queryCode,
selectedType,
sortKey,
sortOrder,
)
}, [queryName, queryCode, selectedType, sortKey, sortOrder, dataService])
}

const handleHeaderClick = (newSortKey) => {
if (newSortKey === sortKey) {
Expand Down

0 comments on commit be792c9

Please sign in to comment.