DEV Community

Cover image for Stop rendering conditions like this

Stop rendering conditions like this

abdelrahman seada on July 15, 2024

we use conditions everywhere on our applications whether for state check or rendering some data into the view depending on some parameters. in this...
Collapse
 
shricodev profile image
Shrijal Acharya • Edited

Just one simple piece of advice: Instead of using 4 spaces for indentation in code snippets for blogs, I think it's better to use 2 spaces as it reduces the need for horizontal scrolling.

Great read. 👌

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks for this advice 🤍

Collapse
 
bop profile image
bop

github.com/gvergnaud/ts-pattern

this is also a good alternative

Collapse
 
abdoseadaa profile image
abdelrahman seada

will try it thanks 💕

Collapse
 
alexmorgun profile image
Alexander Morgun

As always, all gold is in comments :)

Collapse
 
abdulrhmanmoha profile image
abdulrhman-moh

this is awesome

Collapse
 
abdoseadaa profile image
abdelrahman seada

you are awesome

Collapse
 
mohammed_chriatt_6865745c profile image
Mohammed CHRIATT

Thank you 🙏

Collapse
 
abdoseadaa profile image
abdelrahman seada

You're welcome 💕

Collapse
 
threestarss profile image
threestarss • Edited

There is nothing wrong with conditions, you just reshaped the data you are working with

Collapse
 
abdoseadaa profile image
abdelrahman seada

exactly, there is nothing wrong with conditions anyways , it's just a better approach

Collapse
 
kookakoora profile image
KookaKoora

Amazing tip!

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks <3

Collapse
 
abdoseadaa profile image
abdelrahman seada • Edited

didn't expect that anyone would see this post
cat meme

Collapse
 
ehsansafari profile image
Ehsan Safari

You are doing great

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 💕

Collapse
 
tinashe_gunda_697ed0ca338 profile image
Tinashe Gunda

Well executed!

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍

Collapse
 
mxteusg profile image
Mateus Guedes

Nice one!!!

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks :)

Collapse
 
ronakkhunt profile image
Ronak Khunt

Well explained!

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍

Collapse
 
dasezo profile image
Mohammed BENGUEZZOU

Brilliant <3

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍

Collapse
 
kkw855 profile image
KEY UNG KIM

thanks 👌

Collapse
 
abdoseadaa profile image
abdelrahman seada

you are welcome 😌🤍

Collapse
 
alyouma_akmal_5a4d549d061 profile image
alyouma akmal

Nice code

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍

Collapse
 
officialphaqwasi profile image
Isaac Klutse

very understandable.

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍🔥

Collapse
 
01u profile image
Olu

I like this.

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍

Collapse
 
ngocledevmobile profile image
ngocleDevMobile

Greate!!!!!

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 😌

Collapse
 
harshadsatra profile image
Harshad

Nice

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍

Collapse
 
suyash988 profile image
SUYASH AGNIHOTRI

Nice explanation.

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍

Collapse
 
bemimg profile image
Bernardo Guerreiro

great

Collapse
 
abdelrahman_seada_1b2ec1f profile image
Abdelrahman Seada

thanks ♥️

Collapse
 
obere4u profile image
Nwosa Tochukwu

Nice. Thank you for this

Collapse
 
abdoseadaa profile image
abdelrahman seada

thanks 🤍😌

Collapse
 
gabriele_zizzari_3fc98a57 profile image
Gabriele Zizzari

Perfect explanation!!!
simple way to do clean code :)

Collapse
 
abdoseadaa profile image
abdelrahman seada

happy to hear that 💕