From d81b0937f5e36e46415d68806b66707f02fd0ad3 Mon Sep 17 00:00:00 2001 From: Hung Pham Date: Thu, 16 Apr 2026 14:45:43 +0700 Subject: [PATCH] fix(challenge 50): preventing unwanted re-runs with untracked --- .../51-function-call-effect/src/app/action.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/signal/51-function-call-effect/src/app/action.component.ts b/apps/signal/51-function-call-effect/src/app/action.component.ts index 22e0e7a4f..862be23a9 100644 --- a/apps/signal/51-function-call-effect/src/app/action.component.ts +++ b/apps/signal/51-function-call-effect/src/app/action.component.ts @@ -4,6 +4,7 @@ import { effect, inject, signal, + untracked, } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { UserService } from './user.service'; @@ -38,7 +39,11 @@ export class ActionsComponent { constructor() { effect(() => { - this.userService.log(this.action() ?? 'No action selected'); + const action = this.action(); + + untracked(() => { + this.userService.log(action ?? 'No action selected'); + }); }); } }