mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +08:00
fix(data-scope): avoid cyclic invocation of the same API (#4773)
* fix(data-scope): avoid cyclic invocation of the same API * refactor: optimize potentially problematic code
This commit is contained in:
parent
2141e6274d
commit
bf4e100622
@ -39,7 +39,8 @@ export function useParsedFilter({ filterOption }: { filterOption: any }) {
|
||||
_run();
|
||||
const run = _.debounce(_run, DEBOUNCE_WAIT);
|
||||
|
||||
reaction(() => {
|
||||
reaction(
|
||||
() => {
|
||||
// 这一步主要是为了使 reaction 能够收集到依赖
|
||||
const flat = flatten(filterOption, {
|
||||
breakOn({ key }) {
|
||||
@ -66,8 +67,13 @@ export function useParsedFilter({ filterOption }: { filterOption: any }) {
|
||||
},
|
||||
});
|
||||
return flat;
|
||||
}, run);
|
||||
}, [JSON.stringify(filterOption), parseVariableLoading]);
|
||||
},
|
||||
run,
|
||||
{
|
||||
equals: _.isEqual,
|
||||
},
|
||||
);
|
||||
}, [JSON.stringify(filterOption)]);
|
||||
|
||||
return {
|
||||
/** 数据范围的筛选参数 */
|
||||
|
@ -80,7 +80,8 @@ export default function useServiceOptions(props) {
|
||||
|
||||
_run();
|
||||
|
||||
const dispose = reaction(() => {
|
||||
const dispose = reaction(
|
||||
() => {
|
||||
// 这一步主要是为了使 reaction 能够收集到依赖
|
||||
const flat = flatten(filterFromSchema, {
|
||||
breakOn({ key }) {
|
||||
@ -107,7 +108,12 @@ export default function useServiceOptions(props) {
|
||||
},
|
||||
});
|
||||
return flat;
|
||||
}, run);
|
||||
},
|
||||
run,
|
||||
{
|
||||
equals: _.isEqual,
|
||||
},
|
||||
);
|
||||
|
||||
return dispose;
|
||||
}, [
|
||||
|
@ -144,6 +144,9 @@ const useParseDefaultValue = () => {
|
||||
return value;
|
||||
},
|
||||
() => run({ forceUpdate: true }),
|
||||
{
|
||||
equals: _.isEqual,
|
||||
},
|
||||
);
|
||||
|
||||
return dispose;
|
||||
|
@ -15,6 +15,7 @@ import { reaction } from '@formily/reactive';
|
||||
import { uid } from '@formily/shared';
|
||||
import { getValuesByPath } from '@nocobase/utils/client';
|
||||
import { ConfigProvider, Spin, theme } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { useActionContext } from '..';
|
||||
import { useAttach, useComponent, useDesignable } from '../..';
|
||||
@ -180,7 +181,7 @@ const WithForm = (props: WithFormProps) => {
|
||||
return result;
|
||||
},
|
||||
getSubscriber(action, field, rule, variables, localVariables),
|
||||
{ fireImmediately: true },
|
||||
{ fireImmediately: true, equals: _.isEqual },
|
||||
),
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user