DEV Community

Cover image for You can't use if-else in React, and that bothers nobody — astounishing brainwashing
ArtyProg
ArtyProg

Posted on • Edited on

You can't use if-else in React, and that bothers nobody — astounishing brainwashing

At what point have we arrived. A single imposed library succeeded at make us forgotten one of the most basic instruction of all programming languages.

And the vast majority of us have accepted quietly this fact, a veritable absurdity.

Whith that in mind we can conclude : JSX is not Javascript, JSX will not make you a better Javascript developper, it enjails you in its traps.

Look at this Juris code :

const view = {
  div: {
    children: () => {
      if (ctx.getState("error")) return { span: { text: "Error!" } };
      if (!ctx.getState("loaded")) return { span: { text: "Loading..." } };
      return { span: { text: "All good!" } };
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

No tricks. No ternaries. Just logic.

Rediscover the joy of developping with Javascript, don't let any frameworks wash, steal your skills

Here is a part of a discussion I have had wih Copilot :

Top comments (2)

Collapse
 
resti_guay profile image
Resti Guay

The only reactive if/else. I love this article.

Collapse
 
artyprog profile image
ArtyProg

Thank you Resti :-)