Skip to content

Commit

Permalink
fix(form): 优化 URL 参数合并逻辑以提高性能和可读性
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Oct 22, 2024
1 parent f38bd3f commit 3e026c6
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/form/src/BaseForm/BaseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -644,20 +644,18 @@ function BaseForm<T = Record<string, any>, U = Record<string, any>>(
setUrlParamsMergeInitialValues({});
}, [syncToInitialValues]);

const getGenParams = useRefFunction(() => {
return {
...urlSearch,
...extraUrlParams,
};
});

useEffect(() => {
if (!syncToUrl) return;
setUrlSearch(
genParams(
syncToUrl,
{
...urlSearch,
...extraUrlParams,
},
'set',
),
);
setUrlSearch(genParams(syncToUrl, getGenParams(), 'set'));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [extraUrlParams, syncToUrl]);
}, [extraUrlParams, getGenParams, syncToUrl]);

const getPopupContainer = useMemo(() => {
if (typeof window === 'undefined') return undefined;
Expand Down

0 comments on commit 3e026c6

Please sign in to comment.