Skip to content

Commit

Permalink
Merge pull request #146 from betagouv/remove_useless_useeffect
Browse files Browse the repository at this point in the history
refacto: remove useless useEffect
  • Loading branch information
baptou12 authored Nov 6, 2023
2 parents 938bd06 + 5b32ebd commit 0731530
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 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 } from "react"

import useFetchInstitutionsData from "../hooks/fetch-institutions-data"
import InfoIcon from "../components/InfoIcon"
Expand Down Expand Up @@ -39,30 +39,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 0731530

Please sign in to comment.