Skip to content

Commit

Permalink
Refactor conditional in DashboardPage memo hook for toolbarColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
Rokt33r committed Jan 5, 2022
1 parent 60f2cc0 commit 6539b2f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/cloud/components/DashboardPage/DashboardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,14 @@ export const DashboardView = ({
}, [docs, removeDocInSelection])

const toolbarColumns = useMemo(() => {
if (
currentView == null ||
!(currentView.type === 'table' || currentView.type === 'list')
) {
return []
switch (currentView?.type) {
case 'table':
return sortTableViewColumns(currentView.data.columns || {})
case 'list':
return sortListViewProps(currentView.data.props)
default:
return []
}

if (currentView.type === 'table') {
return sortTableViewColumns(currentView.data.columns || {})
}

return sortListViewProps(currentView.data.props)
}, [currentView])

return (
Expand Down

0 comments on commit 6539b2f

Please sign in to comment.