mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(transformer/react): should not collect use-hooks if it's a nested member expression (#6143)
close: #6139 I still remember this logic and I call `get_first_object` for it intentionally 🥲
This commit is contained in:
parent
ab187d1e22
commit
bfd19882b0
2 changed files with 3 additions and 2 deletions
|
|
@ -384,10 +384,11 @@ impl<'a, 'ctx> Traverse<'a> for ReactRefresh<'a, 'ctx> {
|
|||
}
|
||||
|
||||
if !is_builtin_hook(&hook_name) {
|
||||
// Check if a corresponding binding exists where we emit the signature.
|
||||
let (binding_name, is_member_expression) = match &call_expr.callee {
|
||||
Expression::Identifier(ident) => (Some(ident.name.clone()), false),
|
||||
Expression::StaticMemberExpression(member) => {
|
||||
if let Expression::Identifier(object) = member.get_first_object() {
|
||||
if let Expression::Identifier(object) = &member.object {
|
||||
(Some(object.name.clone()), true)
|
||||
} else {
|
||||
(None, false)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export function Bar() {
|
|||
_s();
|
||||
A.B.C.useHook();
|
||||
}
|
||||
_s(Bar, "useHook{}", true);
|
||||
_s(Bar, "useHook{}");
|
||||
_c = Bar;
|
||||
var _c;
|
||||
$RefreshReg$(_c, "Bar");
|
||||
|
|
|
|||
Loading…
Reference in a new issue