forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Filtered index view infinite re-render (twentyhq#5286)
The whole viewBar component was re-rendered on view changes which was introducing performance issue. The need was to compute page title, this should be done in a lower level component
- Loading branch information
1 parent
fa88c03
commit 1db3aae
Showing
2 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/twenty-front/src/modules/views/components/ViewBarPageTitle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { PageTitle } from '@/ui/utilities/page-title/PageTitle'; | ||
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView'; | ||
import { capitalize } from '~/utils/string/capitalize'; | ||
|
||
export type ViewBarPageTitleProps = { | ||
viewBarId: string; | ||
}; | ||
|
||
export const ViewBarPageTitle = ({ viewBarId }: ViewBarPageTitleProps) => { | ||
const { objectNamePlural } = useParams(); | ||
|
||
const { currentViewWithCombinedFiltersAndSorts: currentView } = | ||
useGetCurrentView(viewBarId); | ||
|
||
if (!objectNamePlural) { | ||
return; | ||
} | ||
|
||
const pageTitle = currentView?.name | ||
? `${currentView?.name} - ${capitalize(objectNamePlural)}` | ||
: capitalize(objectNamePlural); | ||
|
||
return <PageTitle title={pageTitle} />; | ||
}; |