Re:Advice on JSX Conditionals
by hombre_fatal on Wednesday March 09, 2022 @12:17PM
(#30617157)
You can add do-expression proposal support in .babelrc:
https://babeljs.io/docs/en/babel-plugin-proposal-do-expressi...
[ Parent
| on HN ]
Or, no need to enable anything:
{user
? <Logout \>
: <Login \>
}
Re:Advice on JSX Conditionals
by hombre_fatal on Wednesday March 09, 2022 @11:33PM
(#30623250)
Yes, my example is trivial, but if-else can easily outgrow the ternary. The do-expression lets you embed arbitrary statements.
Ok this thread just reached peak JavaScript.
Re:Advice on JSX Conditionals
by christophilus on Wednesday March 09, 2022 @01:26PM
(#30618168)
Ternary expressions have been around long before JavaScript was a twinkle in Brandon Eich’s eyes.
Re:Advice on JSX Conditionals
by 9wzYQbTYsAIc on Wednesday March 09, 2022 @02:34PM
(#30618975)
Just modern ECMA Script, not peak JavaScript. ES6 and React Hooks have fully sublimated the web development landscape.