by mietek · 12y ago · 0 comments
React handles mostly the V in MVC, and does an admirable job of it. It even provides a cross-platform event abstraction, which would've saved the author some trouble.
http://facebook.github.io/react/
http://facebook.github.io/react/blog/2013/06/05/why-react.ht...
http://facebook.github.io/react/blog/2013/11/05/thinking-in-...
Now, how about CSS? So far, I've reluctantly chosen Bourbon + Neat + Bitters, which are nice, but not ideal. I appreciate the Sass and semanticism (semanticness, semanticitivity) of it all — no more Bootstrap-like class names in my HTML! However, there aren't enough examples of real pages built with these tools.
Thoughtbot, if you're listening, why not publish at least the Sass sources of these webpages?
https://github.com/thoughtbot/bourbon/tree/gh-pages
https://github.com/thoughtbot/neat/tree/gh-pages
https://github.com/thoughtbot/bitters/tree/gh-pages
I hope that helps! -Chad
React does many things to mitigate those problems and those classes of bugs nearly dropped to 0.
- The code you write is declarative: you say how you want the dom to look like. This means that you no longer have two pieces: creation and retrieval that need to be kept in sync.
- React manages the life cycle of the components. When the component is no longer being rendered, it is properly destroyed, all the listeners are destroyed ...
- The render function is pure. This means that it is easier to write and unit test.
- The code is organized into small, composable and unit testable modules. By having a lot of small components it makes writing complex bug-free code easier.
- Each component has a very well defined interface. It cannot use anything else without it being obvious. This prevents the creation of big chunks of interdependent modules that are impossible to separate.
- There is a single point for state update. This makes the high risk pieces of code stand out.
In the end, we found that React actually helped us write more reliable app compared to framework-less Javascript code.
I think many programmers don't respect how much complexity is reduced when state isn't leaking all over the place.
Of course there will always be times when you need state, but many times its worth jumping through a few hoops to make things work without state.
EDIT: If programmers learn C so they can think lower level, they should learn Haskell so they can think in terms of side effects, composability, and the advantages of pure functions. Just a reminder, pure functions can be created in any language though some (Clojure, Haskell) enforce purity.
From the React site: "React as the V in MVC".
It's perfectly normal to combine react with something like Backbone as more complete solution.