Skip to content

Commit

Permalink
Fix useEffect array dependencies for pages with tabs; causes issues o…
Browse files Browse the repository at this point in the history
…n Table view
  • Loading branch information
johnnadeluy committed Feb 28, 2024
1 parent 12bd39c commit 418edee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/pages/TeamMembers/TeamMembers.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useCallback, useEffect, useState } from 'react'
import { Dialog, Text, Link, Tabs, Divider } from '@statisticsnorway/ssb-component-library'

Expand Down Expand Up @@ -57,13 +58,13 @@ const TeamMembers = () => {
.catch((error) => {
setError(error as ApiError)
})
}, [prepUserData, jwt])
}, [])

useEffect(() => {
if (teamMembersData) {
setTeamMembersTableData(prepUserData(teamMembersData))
setTeamMembersTableData(prepUserData(teamMembersData)) // Update Table view on Tab onClick
}
}, [teamMembersData, prepUserData])
}, [prepUserData])

const handleTabClick = (tab: string) => {
setActiveTab(tab)
Expand Down
7 changes: 4 additions & 3 deletions src/pages/TeamOverview/TeamOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useCallback, useEffect, useState } from 'react'
import { Dialog, Text, Link, Tabs, Divider } from '@statisticsnorway/ssb-component-library'

Expand Down Expand Up @@ -54,13 +55,13 @@ const TeamOverview = () => {
.catch((error) => {
setError(error.toString())
})
}, [prepTeamData])
}, [])

useEffect(() => {
if (teamOverviewData) {
setTeamOverviewTableData(prepTeamData(teamOverviewData))
setTeamOverviewTableData(prepTeamData(teamOverviewData)) // Update Table view on Tab onClick
}
}, [teamOverviewData, prepTeamData])
}, [prepTeamData])

const handleTabClick = (tab: string) => {
setActiveTab(tab)
Expand Down

0 comments on commit 418edee

Please sign in to comment.