Skip to content

Commit

Permalink
fix: fix a dashboard useEffect function
Browse files Browse the repository at this point in the history
  • Loading branch information
KimJoonSeo committed Dec 13, 2023
1 parent 8378efd commit 1b20877
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/components/DashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ export const DashBoard: React.FC<Props> = ({ date, league }) => {
const { state, actions} = useContext(PaginationContext)

useEffect(() => {
actions.setCurrentPage(1)
actions.setTotalCount(1)
if (error) {
actions.setCurrentPage(1)
actions.setTotalCount(1)
showMessage('error', 'An error has occurred while fetching data.')
}
if (data?.events.length === 0) {
actions.setCurrentPage(1)
actions.setTotalCount(1)
showMessage('info', 'No game today!')
} else if (typeof data?.events !== 'undefined') {
actions.setCurrentPage(1)
actions.setTotalCount(data?.events.length)
}
}, [data, error])
Expand Down

0 comments on commit 1b20877

Please sign in to comment.