A Brief History of client-side JS: Why React is Awesome
React (2013)
Backbone (2010)
Any Questions?
jQuery (2006)
Pros
Pros
Pros
Coupling Hell
Indirect DOM Manipulation
var hiddenBox = $( "#banner-message" );
$( "#button-container button" ).on( "click", function( event ) {
hiddenBox.show();
});
Direct DOM Manipulation
- Auto-synced models via REST API
- Compatible well with other libraries
- Robust event system
- Documentation
$( "button.click-me" ).html( "Next Step..." )
HTML
<div class="some-class" id="some-id">
<button class="click-me">
Click Me!
</button>
</div>
Components
State vs Props
- Cross-browser API
- Powerful DOM Manipulation
- Painless Ajax
- Components, not templates
- Business Logic and UI in the same context
- Encourage High Cohesion & Loose Coupling
- Abstraction, Composition, Expressivity
- Reusable, Composable, Unit Testable
- Components store data using State & Props
- JSX views
- State is only used in root components
- Props are passed from parent to child components
- Props are immutable
- State is mutable
https://facebook.github.io/react/docs/tutorial.html
- Minimal (only UI layer)
- Immutable data across views
- No data-binding whatsoever
- Compatible with other libraries
- Virtual DOM provides fastest view rendering (60fps) due to idempotent DOM manipulations
- Documentation
- Backed by Facebook
Cons
Cons
- Bare-bones features
- Lots of Boilerplate
- Views suck (jQuery style)
- DOM Manipulation is slow
- Tight Coupling with HTML tags leads to scattered spaghetti code
- Extremely difficult to track DOM event handlers
Cons
- Re-establishes best practices
- Change of mindset
2007
2010
2015
2020
2000
Ember (2011)
Angular (2009)
Pros
Pros
- True MVC pattern with Rails-like magic
- Handlebars' robust templating system
- Backed by Rails community
- Two-way Data Binding
- Declarative HTML
- Backed by Google
?
Cons
Cons
Two-Way Data Binding
JS ($scope)
DOM
- Too much magic behind the scenes make it harder to learn
- Lots of context switching
- Two-way data binding much more complicated
- Documentation
- Directives are hard
- Dirty Checking is slow
- Redefining well-established terminology
- Logic all over the place