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