Skip to content

Commit

Permalink
Merge pull request #696 from jdegand/bug-cd-md
Browse files Browse the repository at this point in the history
docs: add note to bug-cd-md
  • Loading branch information
tomalaforge authored Mar 18, 2024
2 parents 3aa4561 + dab5143 commit 790d69c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/src/content/docs/challenges/angular/32-bug-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ In this small application, we have a navigation menu to route our application to

The goal of the challenge is to debug this application and make it work.

:::note
Without knowing the exact reason for the issue, you can "fix" the error and get the program to function. One such approach would be to memoize `getMenu`. The application might work again, but make sure you really understand the problem and its consequences. Making it work isn't always enough; fixing this bug in the wrong way can cause a loss of performance or lead to other problems later on.
:::

## Hints

<details>
Expand All @@ -36,6 +40,6 @@ The goal of the challenge is to debug this application and make it work.
<details>
<summary>Hint 2</summary>

If you open the [`RouterLinkActive` source code](https://github.com/angular/angular/blob/main/packages/router/src/directives/router_link_active.ts) and go to **line 196**, Angular is calling `this.cdr.markForCheck` inside a microTask which triggers a new CD cycle. If you comment out this line, the application loads again, however the bug is not inside the Angular Framework. 😅😯
If you open the [`RouterLinkActive` source code](https://github.com/angular/angular/blob/main/packages/router/src/directives/router_link_active.ts) and go to **line 196**, Angular is calling `this.cdr.markForCheck` inside a microTask, which triggers a new CD cycle. If you comment out this line, the application loads again, however, the bug should not be fixed by changing the Angular source code. 😅😯

</details>

0 comments on commit 790d69c

Please sign in to comment.