refactor: rename setSorts to onSortsUpdate
This commit is contained in:
@ -9,7 +9,7 @@ import { useState } from 'react';
|
||||
type OwnProps = {
|
||||
viewName: string;
|
||||
viewIcon?: IconProp;
|
||||
setSorts?: React.Dispatch<React.SetStateAction<SortType[]>>;
|
||||
onSortsUpdate?: React.Dispatch<React.SetStateAction<SortType[]>>;
|
||||
};
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
@ -44,17 +44,8 @@ const StyledFilters = styled.div`
|
||||
margin-right: ${(props) => props.theme.spacing(2)};
|
||||
`;
|
||||
|
||||
function TableHeader({
|
||||
viewName,
|
||||
viewIcon,
|
||||
setSorts: parentSetSorts,
|
||||
}: OwnProps) {
|
||||
const [sorts, localSetSorts] = useState([] as Array<SortType>);
|
||||
|
||||
const setSorts = (value: React.SetStateAction<SortType[]>) => {
|
||||
parentSetSorts && parentSetSorts(value);
|
||||
localSetSorts(value);
|
||||
};
|
||||
function TableHeader({ viewName, viewIcon, onSortsUpdate }: OwnProps) {
|
||||
const [sorts, setSorts] = useState([] as Array<SortType>);
|
||||
|
||||
const onSortItemSelect = (sortId: string) => {
|
||||
setSorts([
|
||||
@ -64,6 +55,7 @@ function TableHeader({
|
||||
id: sortId,
|
||||
},
|
||||
]);
|
||||
onSortsUpdate && onSortsUpdate(sorts);
|
||||
};
|
||||
|
||||
const onSortItemUnSelect = (sortId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user