Skip to content

Commit 5f142a5

Browse files
authored
fix: prevent infinite re-render caused by unstable dependencies (#1394)
1 parent a3c028e commit 5f142a5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/components/src/utils/hooks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Algorithm } from '@rsdoctor/utils/common';
22
import { Client, Manifest, Rule, SDK } from '@rsdoctor/types';
33
import { uniqBy, defaults } from 'es-toolkit/compat';
4-
import { useEffect, useState } from 'react';
4+
import { useEffect, useMemo, useState } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import { useNavigate, useLocation } from 'react-router-dom';
77
import parse from 'url-parse';
@@ -47,8 +47,8 @@ export function useRuleIndexNavigate(code: string, link?: string | undefined) {
4747

4848
export function useUrlQuery() {
4949
const search = useLocation().search || location.search;
50-
const { query } = parse(search, true);
51-
return query;
50+
51+
return useMemo(() => parse(search, true).query, [search]);
5252
}
5353

5454
export function useLoading(defaultLoading = false) {

0 commit comments

Comments
 (0)