From 877c490fa3ab5ea23d5b35a55a9139d8a200a6ba Mon Sep 17 00:00:00 2001 From: Mofei Zhang Date: Wed, 27 Mar 2024 20:26:16 -0400 Subject: [PATCH] [visitors] Visit loop body before update --- .../src/ReactiveScopes/PropagateScopeDependencies.ts | 2 +- .../babel-plugin-react-forget/src/ReactiveScopes/visitors.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateScopeDependencies.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateScopeDependencies.ts index f86146e0e0..1e814c7cc5 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateScopeDependencies.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateScopeDependencies.ts @@ -681,10 +681,10 @@ class PropagationVisitor extends ReactiveFunctionVisitor { this.visitReactiveValue(context, terminal.id, terminal.init); this.visitReactiveValue(context, terminal.id, terminal.test); context.enterConditional(() => { + this.visitBlock(terminal.loop, context); if (terminal.update !== null) { this.visitReactiveValue(context, terminal.id, terminal.update); } - this.visitBlock(terminal.loop, context); }); break; } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts index 9e2fddfbda..def9c9dd03 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/visitors.ts @@ -124,10 +124,10 @@ export class ReactiveFunctionVisitor { case "for": { this.visitValue(terminal.id, terminal.init, state); this.visitValue(terminal.id, terminal.test, state); + this.visitBlock(terminal.loop, state); if (terminal.update !== null) { this.visitValue(terminal.id, terminal.update, state); } - this.visitBlock(terminal.loop, state); break; } case "for-of": {