Fix excessive re-rendering due to route changesd
This commit is contained in:
parent
7b0e2ce99d
commit
8bd518048e
7 changed files with 51 additions and 27 deletions
|
@ -6,16 +6,15 @@ import FlashMessageRender from '@/components/FlashMessageRender';
|
|||
import { Link } from 'react-router-dom';
|
||||
import PaginationFooter from '@/components/elements/table/PaginationFooter';
|
||||
import { DesktopComputerIcon, XCircleIcon } from '@heroicons/react/solid';
|
||||
import { useLocation } from 'react-router';
|
||||
import Spinner from '@/components/elements/Spinner';
|
||||
import { styles as btnStyles } from '@/components/elements/button/index';
|
||||
import classNames from 'classnames';
|
||||
import ActivityLogEntry from '@/components/elements/activity/ActivityLogEntry';
|
||||
import Tooltip from '@/components/elements/tooltip/Tooltip';
|
||||
import useLocationHash from '@/plugins/useLocationHash';
|
||||
|
||||
export default () => {
|
||||
const location = useLocation();
|
||||
|
||||
const { hash } = useLocationHash();
|
||||
const { clearAndAddHttpError } = useFlashKey('account');
|
||||
const [ filters, setFilters ] = useState<ActivityLogFilters>({ page: 1, sorts: { timestamp: -1 } });
|
||||
const { data, isValidating, error } = useActivityLogs(filters, {
|
||||
|
@ -24,10 +23,8 @@ export default () => {
|
|||
});
|
||||
|
||||
useEffect(() => {
|
||||
const parsed = new URLSearchParams(location.search);
|
||||
|
||||
setFilters(value => ({ ...value, filters: { ip: parsed.get('ip'), event: parsed.get('event') } }));
|
||||
}, [ location.search ]);
|
||||
setFilters(value => ({ ...value, filters: { ip: hash.ip, event: hash.event } }));
|
||||
}, [ hash ]);
|
||||
|
||||
useEffect(() => {
|
||||
clearAndAddHttpError(error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue