The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
bugfix: remove infinite renderloop of onSortUpdate
Sammy Teillet2acd98370dd1
diff --git a/front/src/components/table/table-header/TableHeader.tsx b/front/src/components/table/table-header/TableHeader.tsxindex dca266985fc..0510a56aae8 100644--- a/front/src/components/table/table-header/TableHeader.tsx+++ b/front/src/components/table/table-header/TableHeader.tsx@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';import DropdownButton from './DropdownButton';import { IconProp } from '@fortawesome/fontawesome-svg-core';import SortAndFilterBar, { SortType } from './SortAndFilterBar';-import { useEffect, useState } from 'react';+import { useState } from 'react';type OwnProps = {viewName: string;@@ -53,22 +53,23 @@ function TableHeader({const [sorts, setSorts] = useState([] as Array<SortType>);const onSortItemSelect = (sortId: string) => {- setSorts([+ const newSorts = [{label: 'Created at',order: 'asc',id: sortId,} as SortType,- ]);+ ];+ setSorts(newSorts);+ onSortsUpdate && onSortsUpdate(newSorts);};+const onSortItemUnSelect = (sortId: string) => {- setSorts([]);+ const newSorts = [] as SortType[];+ setSorts(newSorts);+ onSortsUpdate && onSortsUpdate(newSorts);};- useEffect(() => {- onSortsUpdate && onSortsUpdate(sorts);- }, [sorts, onSortsUpdate]);-return (<StyledContainer><StyledTableHeader>