Skip to content

Commit

Permalink
fix(SortList): union useMemo calls
Browse files Browse the repository at this point in the history
  • Loading branch information
LamaEats committed Jul 31, 2024
1 parent d8a4075 commit 2fe1968
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/components/SortList/SortList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ interface SingleSortItem {
}

export const SortList: React.FC<SortListProps> = ({ value, onChange }) => {
const sortItems: { [K in SortableProps]: string } = useMemo(
() => ({
const { itemsToRender, sortItems } = useMemo(() => {
const sortItems = {
title: tr('Title'),
state: tr('State'),
priority: tr('Priority'),
Expand All @@ -29,17 +29,17 @@ export const SortList: React.FC<SortListProps> = ({ value, onChange }) => {
owner: tr('Owner'),
updatedAt: tr('UpdatedAt'),
createdAt: tr('CreatedAt'),
}),
[],
);
};

const itemsToRender: SingleSortItem[] = useMemo(() => {
return (Object.entries(sortItems) as Array<[SortableProps, string]>).map(([id, title]) => ({
id,
title,
dir: null,
}));
}, [sortItems]);
return {
sortItems,
itemsToRender: (Object.entries(sortItems) as Array<[SortableProps, string]>).map(([id, title]) => ({
id,
title,
dir: null,
})),
};
}, []);

const selected: SingleSortItem[] | undefined = useMemo(() => {
return value?.map(({ key, dir }) => ({ id: key, title: sortItems[key], dir }));
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useUrlFilterParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface FilterQueryState {
participant: string[];
project: string[];
query: string;
sort: Array<{ key: SortableProps; dir: Exclude<SortDirection, null> }>;
sort: Array<{ key: SortableProps; dir: SortDirection }>;
}

const groupByValue = {
Expand Down

0 comments on commit 2fe1968

Please sign in to comment.