Skip to content

fix(issues): Fix a problem were 0 may be rendered#108403

Merged
ryan953 merged 2 commits intomasterfrom
ryan953/fix-conditional-render-bug
Feb 17, 2026
Merged

fix(issues): Fix a problem were 0 may be rendered#108403
ryan953 merged 2 commits intomasterfrom
ryan953/fix-conditional-render-bug

Conversation

@ryan953
Copy link
Copy Markdown
Member

@ryan953 ryan953 commented Feb 17, 2026

Remember that && is an operator that returns the value of the first falsy operand from left to right, and if all are truthy you get the value of the last operand.

So if a.length is 0 then it'll return 0. React is happy to render 0.

I strongly recommend to people not to use && for this reason. Use a ternary ? : and handle both case!

@ryan953 ryan953 requested a review from a team as a code owner February 17, 2026 22:38
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 17, 2026
@ryan953 ryan953 requested a review from a team February 17, 2026 22:39
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@ryan953 ryan953 merged commit fbe2a59 into master Feb 17, 2026
61 checks passed
@ryan953 ryan953 deleted the ryan953/fix-conditional-render-bug branch February 17, 2026 23:16
mchen-sentry pushed a commit that referenced this pull request Feb 24, 2026
Remember that `&&` is an operator that returns the value of the first
falsy operand from left to right, and if all are truthy you get the
value of the last operand.

So if `a.length` is `0` then it'll return `0`. React is happy to render
`0`.

I strongly recommend to people not to use `&&` for this reason. Use a
ternary `? :` and handle both case!
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants