refactor: avoid errors (#3091)
* refactor: avoid errors * refactor: remove useless code
This commit is contained in:
parent
e5f711ec66
commit
85be616f35
@ -103,7 +103,6 @@ const WithForm = (props: WithFormProps) => {
|
||||
useEffect(() => {
|
||||
const id = uid();
|
||||
const disposes = [];
|
||||
const linkagefields = [];
|
||||
|
||||
form.addEffects(id, () => {
|
||||
linkageRules.forEach((v, index) => {
|
||||
@ -126,9 +125,9 @@ const WithForm = (props: WithFormProps) => {
|
||||
|
||||
// 之前使用的 `onFieldReact` 有问题,没有办法被取消监听,所以这里用 `onFieldInit` 和 `autorun` 代替
|
||||
onFieldInit(`*(${fields})`, (field: any, form) => {
|
||||
field.linkageProperty = {};
|
||||
disposes.push(
|
||||
autorun(async () => {
|
||||
linkagefields.push(field);
|
||||
await linkageMergeAction({
|
||||
operator: h.operator,
|
||||
value: h.value,
|
||||
@ -138,15 +137,6 @@ const WithForm = (props: WithFormProps) => {
|
||||
variables,
|
||||
localVariables,
|
||||
});
|
||||
if (index === linkageRules.length - 1) {
|
||||
// 如果不在这里使用 setTimeout 会在某些未知情况下导致死循环,原因未知
|
||||
setTimeout(() => {
|
||||
linkagefields.forEach((v) => {
|
||||
v.linkageProperty = {};
|
||||
});
|
||||
linkagefields.length = 0;
|
||||
});
|
||||
}
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user