unnötige useState und useEffect entfernen
This commit is contained in:
parent
66ab925b5d
commit
b8e2100331
@ -31,15 +31,6 @@ export function DocSearchView({ posts }: Props) {
|
||||
|
||||
const [filters, setFilters] = useState<Filter[]>([])
|
||||
|
||||
const [disabledStates, setDisabledStates] = useState<Record<number, boolean>>({});
|
||||
|
||||
const setDisabledState = useCallback((index: number, state: boolean) => {
|
||||
setDisabledStates(prev => ({
|
||||
...prev,
|
||||
[index]: state,
|
||||
}));
|
||||
}, []);
|
||||
|
||||
const handleSort = useCallback((newSort: string) => {
|
||||
setSortBy(newSort);
|
||||
}, []);
|
||||
@ -47,13 +38,6 @@ export function DocSearchView({ posts }: Props) {
|
||||
useEffect(() => {
|
||||
getFiltersAsync().then((res) => {
|
||||
setFilters(res);
|
||||
const newDisabledStates = res.reduce<Record<number, boolean>>((acc, filter, index) => {
|
||||
if (filter.type === 'BOOLEAN') {
|
||||
acc[index] = true;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
setDisabledStates(newDisabledStates);
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user