From ef62b9dacc2e4f0b98f61898c98fab2ca1075a56 Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:12:11 +0000 Subject: [PATCH] refactor(transformer/react-refresh): use `generate_uid_in_current_hoist_scope` to add hoisted binding (#7492) --- crates/oxc_transformer/src/jsx/refresh.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/crates/oxc_transformer/src/jsx/refresh.rs b/crates/oxc_transformer/src/jsx/refresh.rs index 0180bce8e..0b0871532 100644 --- a/crates/oxc_transformer/src/jsx/refresh.rs +++ b/crates/oxc_transformer/src/jsx/refresh.rs @@ -582,14 +582,7 @@ impl<'a, 'ctx> ReactRefresh<'a, 'ctx> { arguments.push(function); } - // TODO: Handle var hoisted in ctx API - let target_scope_id = ctx - .scopes() - .ancestors(ctx.current_scope_id()) - .find(|&scope_id| ctx.scopes().get_flags(scope_id).is_var()) - .unwrap_or_else(|| ctx.current_scope_id()); - - let binding = ctx.generate_uid("s", target_scope_id, SymbolFlags::FunctionScopedVariable); + let binding = ctx.generate_uid_in_current_hoist_scope("s"); // _s(); let call_expression = ctx.ast.statement_expression(