|
|
|
|
|
by tigershark
3228 days ago
|
|
Ah ok.
So for you using a map with a ternary operator over a list of objects in JSX is perfectly fine and you can't see what is wrong.
I don't know Vue.js, but in WPF I would have simply bound an ItemsConttol to the list of models.
Stop. Finished. No presentation logic at all in the XAML file.
WPF will automatically bind the correct DataTemplate to the specific ViewModel contained in the list.
I would have never ever approved a pull request in which someone implemented that using a monstrosity similar to the one shown in this thread.
The XAML file, as the HTML layer, should be completely devoid of logic and should delegate the whole work to the underlying model.
Reading this thread, apparently in React is encouraged to do whatever sh@t you want directly in the JSX file rather than delegating it to where it belongs.
Heck, you are even excited that JSX is Turing complete, as if it was a good thing.
I will continue happily to write my code respecting the separation of concerns, leaving all the logic out of the XAML or HTML.
You are free to continue to put everything in the JSX if you like it, but don't expect me to stay silent when you mislead many people in thinking that writing logic in JSX is the right way to go. |
|
I don't really know JSX much and without a specific example this is pointless to discuss. But basically JSX is syntactic sugar over javascript. A ternary is just a "if" condition so I don't see where is the issue here. Are you really using a template language devoid of conditionals? Even mustache the "logic-less" template has a form of it.
> The XAML file, as the HTML layer, should be completely devoid of logic and should delegate the whole work to the underlying model
The role of the model is and has always been to handle /business/ logic not presentational logic. If you put your dirty presentational logic inside my models I can tell you I will /never never/ accept your pull request.