TGViewer
Diyorbek.dev | 👨🏻‍💻 Diyorbek.dev | 👨🏻‍💻 @diyorbekk_dev · 381 subscribers
Post #740 95
Diyorbek.dev | 👨🏻‍💻 #Common_Beginner_Mistakes_with_React Question number: 1 Who can find the bug here? 😉 @Diyorbekk_dev
#answer

Question number: 1 [answer]

Our goal is to conditionally show a shopping list. If we have at least 1 item in the array, we should render a ShoppingList element. Otherwise, we shouldn't render anything.

And yet, we wind up with a random 0 in the UI!

This happens because items.length evaluates to 0. And since 0 is a falsy value in JavaScript, the && operator short-circuits, and the entire expression resolves to 0.

&& - false ni izlab yuradi.

@Diyorbekk_dev
  • 👍 1
  • 🔥 1
More from @diyorbekk_dev
  1. Sep 15, 2026ChatGPT and Codex now support TSRX syntax Highlighting! #tsrx #OctaneJS
  2. Sep 14, 2026Tanner Linsleydan yangilik. Hozirgacha Tanstack Team Octane uchun katta yordam berib kelmo…
  3. Sep 10, 2026Octane Js Hozirda Instagramda bitta content topoldim. Nasib tez kunda òzim yangiliklar qòy…
  4. Sep 9, 2026Ajoyib yangiliklardan biri. Tez orada Open AI butunlay òtadi nasib OctaneJs’ga. Tarqatmay…
  5. Sep 5, 2026Yangi joyni ham tizimlashtirdik. Bir qancha yangi imkoniyatlar qo‘shildi va yangi funksiya…
  6. Sep 5, 2026photo post
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →