Skip to content

Commit 6d0071e

Browse files
surt91github-actions[bot]
authored andcommitted
chore: add exceptions for new linter rule or replace by something better
1 parent 58c7cd2 commit 6d0071e

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

frontend/src/components/Logo.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function Logo(props: LogoProps) {
2121
const [path, setPath] = useState<string>('');
2222
const [loaded, setLoaded] = useState(false);
2323

24+
/* eslint-disable react-hooks/set-state-in-effect -- Resetting state and creating object URL when props change is a valid effect pattern */
2425
useEffect(() => {
2526
setLoaded(false);
2627

@@ -38,6 +39,7 @@ export function Logo(props: LogoProps) {
3839

3940
setPath(window.URL.createObjectURL(previewLogo));
4041
}, [url, previewLogo]);
42+
/* eslint-enable react-hooks/set-state-in-effect */
4143

4244
return path ? (
4345
<img

frontend/src/components/PdfViewer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ export function PdfViewer({ selectedDocument, selectedSource, onClose }: PdfView
7979
setNumPages(numPages);
8080
}
8181

82+
/* eslint-disable react-hooks/set-state-in-effect -- Processing fetched document data is a valid effect pattern */
8283
useEffect(() => {
8384
handleSelectedPdfDocument();
8485
}, [data, handleSelectedPdfDocument]);
86+
/* eslint-enable react-hooks/set-state-in-effect */
8587

8688
const container = (children: ReactNode) => (
8789
<Card withBorder mt="sm" mr="xs" ml="6">

frontend/src/hooks/stored.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'reac
22
import { isMobile } from 'src/pages/utils';
33

44
export function useSidebarState(key: string): [boolean, (value: boolean) => void] {
5-
const [state, setState] = useState(!isMobile());
6-
7-
useEffect(() => {
5+
const [state, setState] = useState(() => {
6+
if (isMobile()) {
7+
return false;
8+
}
89
const fromLocalStore = localStorage.getItem(key);
9-
10-
if (!isMobile()) setState(fromLocalStore !== 'false');
11-
}, [key]);
10+
return fromLocalStore !== 'false';
11+
});
1212

1313
const update = useCallback(
1414
(value: boolean) => {

frontend/src/pages/admin/extensions/ExtensionsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function ExtensionsPage() {
3838
queryFn: () => api.extensions.getConfiguration(configurationId),
3939
});
4040

41+
/* eslint-disable react-hooks/set-state-in-effect -- Keeping previous value during refetch avoids UI flicker */
4142
useEffect(() => {
4243
if (configuration) {
4344
const updatedConfiguration = configurations.find((c) => c.id == configuration.id);
@@ -46,6 +47,7 @@ export function ExtensionsPage() {
4647
}
4748
}
4849
}, [configuration, configurations]);
50+
/* eslint-enable react-hooks/set-state-in-effect */
4951

5052
const deletingConfiguration = useMutation({
5153
mutationFn: (configuration: ConfigurationDto) => {

frontend/src/pages/admin/users/UsersPage.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button } from '@mantine/core';
22
import { IconPlus } from '@tabler/icons-react';
33
import { useQuery } from '@tanstack/react-query';
4-
import { useEffect, useState } from 'react';
4+
import { useCallback, useEffect, useState } from 'react';
55
import { useApi, UserDto, UserGroupDto } from 'src/api';
66
import { Page, Pagination, Search } from 'src/components';
77
import { useEventCallback } from 'src/hooks';
@@ -22,6 +22,11 @@ export function UsersPage() {
2222
const [toCreate, setToCreate] = useState<boolean>();
2323
const [toUpdate, setToUpdate] = useState<UserDto | null>(null);
2424

25+
const handleSearch = useCallback((newQuery: string | undefined) => {
26+
setQuery(newQuery);
27+
setPage(0);
28+
}, []);
29+
2530
const { data: loadedUsers, isFetched } = useQuery({
2631
queryKey: ['users', page, query],
2732
queryFn: () => api.users.getUsers(page, 20, query),
@@ -38,10 +43,6 @@ export function UsersPage() {
3843
}
3944
}, [loadedUsers, setUsers]);
4045

41-
useEffect(() => {
42-
setPage(0);
43-
}, [query]);
44-
4546
const doChangePage = useEventCallback((page: number) => {
4647
setPage(page);
4748
});
@@ -60,7 +61,7 @@ export function UsersPage() {
6061
<h2 className="text-3xl">{texts.users.headline}</h2>
6162

6263
<div className="flex gap-4">
63-
<Search value={query} onSearch={setQuery} />
64+
<Search value={query} onSearch={handleSearch} />
6465

6566
<Button onClick={() => setToCreate(true)}>
6667
<IconPlus className="mr-2" /> {texts.users.create}

0 commit comments

Comments
 (0)