feat(compiler-cli): detect isPlatformBrowser usage inside control flow (hydration warning)#68525
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Thanks for the detailed feedback! @SkyZeroZx I've updated the implementation to:
All tests are now passing locally. Please let me know if anything else should be improved. |
88b21b6 to
aeaea94
Compare
There was a problem hiding this comment.
One of your three commits are authored as your-github-email@example.com. Only 26e0d8f has your real email. The CLA bot will fail on this one and it won't link to your GitHub account. Per CONTRIBUTING.md, every commit needs to be authored with the email tied to your CLA signature.
While you're at it, you could squash all three into a single commit since they're all part of the same feature. Fix with git config user.email bhuvanshkataria@gmail.com, then git rebase -i HEAD~3 (mark the second and third as squash/fixup, and use git commit --amend --reset-author to fix the author on the resulting commit) and force-push.
…l flow Adds an extended template diagnostic to detect usage of isPlatformBrowser() inside control flow blocks. This pattern can cause hydration re-rendering and UI flicker. Fixes angular#59223
aeaea94 to
0c8ffa2
Compare
Thanks for the feedback! @erkamyaman I've squashed the commits into a single commit and fixed the author email to match my CLA. Please let me know if anything else should be improved. |
|
@BHUVANSH855 No need to ping us, we'll review the PRs in due time. |
|
Just checking in regarding the updates to this PR. Thank you! |
Overview
Adds an extended template diagnostic to detect usage of
isPlatformBrowser()inside template control flow blocks (e.g.@if).While this pattern is supported and does not break hydration, it can negatively impact user experience by causing a brief display of server-rendered content followed by a re-render, resulting in UI flicker.
Fixes #59223
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What is the current behavior?
Currently, using
isPlatformBrowser()inside control flow blocks such as@ifis allowed and does not break hydration, but it may cause UI flicker due to re-rendering on the client.Issue Number: #59223
What is the new behavior?
A new extended template diagnostic is introduced:
isPlatformBrowser()inside control flow blocksExample:
@if (isPlatformBrowser()) { <div>Browser-only content</div> }Does this PR introduce a breaking change?
Other Information
ALL_DIAGNOSTIC_FACTORIES