refactor: avoid errors (#3091)

* refactor: avoid errors

* refactor: remove useless code
This commit is contained in:
被雨水过滤的空气-Rain 2023-11-24 21:46:19 +08:00 committed by GitHub
parent e5f711ec66
commit 85be616f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
});
}
}),
);
});