> However, all template languages are inherently crippled: they can never achieve the same expressiveness and power as code. Quite simply, {{# each}}, ng-repeat and databind="foreach" are all poor replacements for something that is native and trivial in JavaScript: a for loop. On the other hand, when using a template language I can put `foreach` loops and `if` conditions right into the template itself. And when using…
Which is why I prefer Ractive.js to React.
How I learned to stop worrying and love React
31–40 of 107 posts
Re: How I learned to stop worrying and love React
#32Re: How I learned to stop worrying and love React
#33I went through something similar...and then I found Mithril ( http://lhorie.github.io/mithril/ ). I may be alone on this, but I've enjoyed working with Mithril much more than I ever did React. If you haven't given it a shot, I highly recommend you do.
Mithril didn't quite have everything we needed, though, so we made a small wrapper that provides nicer templating, event delegation, etc.: https://github.com/dailymuse/mithril-coat
Re: How I learned to stop worrying and love React
#34Maybe JS developers should go through it, through this circle of hell, to avoid it in future, so JSX is necessary evil.
//despite of that, I sincerely thankful for people behind React, for their new ideas and how they changed fields of JS frameworks and mobile apps. Big respect!
Re: How I learned to stop worrying and love React
#35Re: How I learned to stop worrying and love React
#36I went through something similar...and then I found Mithril ( http://lhorie.github.io/mithril/ ). I may be alone on this, but I've enjoyed working with Mithril much more than I ever did React. If you haven't given it a shot, I highly recommend you do.
I like Mithril a lot, but the only thing that puts me off it over React and Angular is I don't really know how to tie in third-party libraries like d3 and dropzone.
You can use the same approach for other libraries:
Add a function as `config` attribute to your virtual DOM element. That function gets the real DOM element as a parameter, and you can act on it with third party libraries.
Re: How I learned to stop worrying and love React
#37I recently worked on my first React project, after working with Angular code for a while. I'm willing to accept that as an app gets more complex, React/Flux really pays off. But there's something to be said for having a single template file for a single page in Angular, versus having JSX scattered among 20+ components for that same single page in React. When you want to get a 10,000-foot-view of how it all comes toge…
Re: How I learned to stop worrying and love React
#38I went through something similar...and then I found Mithril ( http://lhorie.github.io/mithril/ ). I may be alone on this, but I've enjoyed working with Mithril much more than I ever did React. If you haven't given it a shot, I highly recommend you do.
What makes you like Mithril more? I've been looking at it for a while, and it seems very nice and lightweight. All I really want is an easy way to get performant DOM manipulations. With React I have to build the whole view around the component system, which isn't so flexible. Am I right in thinking that Mithril allows you to put the view together any way you want, as long as the end result is an object it can diff in…
That's correct. Virtual DOM nodes are plain JS objects with `tag`, `attr` and `children` attributes (the last two being optional).
The `m()` helper gives you some sugar on top of that.
Idiomatic Mithril view code, however, is more about declaratively generating vDOM nodes based on a model and/or a view model than, say, jQuery-style DOM manipulations...
Re: How I learned to stop worrying and love React
#39There is a lot of good and even awesome things in ReactJS universe, except JSX. Thousands of developers took their lessons in PHP/Perl/Python about mixing logic and representation, and now in nightmares they will generate HTML from logic, especially by parts and in worst case - using conditional cases. Everybody who tried to change design of website, written using something like "if ($birthday) $html .= getBirthdayBu…
Logic and representation are not two unrelated pieces to keep them separate.
Re: How I learned to stop worrying and love React
#40There is a lot of good and even awesome things in ReactJS universe, except JSX. Thousands of developers took their lessons in PHP/Perl/Python about mixing logic and representation, and now in nightmares they will generate HTML from logic, especially by parts and in worst case - using conditional cases. Everybody who tried to change design of website, written using something like "if ($birthday) $html .= getBirthdayBu…
Don't think of React as "a container for logic and a system for doing views". Think of it solely as view logic.
It's not mixing views with program logic. It's only view. There's nothing to mix. It just happens --- wonderfully --- to use a real programming language to represent those views.
The notions of logic, controllers, models, storage, and all that jazz are why there's also Flux (or Backbone or whatever else it is you want to use; we use Flummox, it's fine).