On May 14, 2015, Jeff Winkler gave a talk at Harvard University's Lamont Library titled "Intro to ReactJS."
Description
Created by Facebook and Instagram, React has recently been embraced by companies and organizations including Airbnb, Khan Academy, Reddit, the BBC, and Code Academy. This presentation will be especially interesting for those using or planning to use javascript libraries such as angularJS, backbone.js, ember.js, and others.
For this talk, Jeff Winkler will present:
- An introduction to React, mixed with demos.
- An examination of how React implements Computer Science principles from Functional and Object-Oriented. The discussion will consider the impact on maintainable large-scale systems.
Biography
Jeff Winkler, is a professional developer* in the Boston area and organizer of the Boston ReactJS Meetup. In addition to the ReactJS Boston Meetup, Jeff works with React professionally at TapJoy and runs http://react.rocks.
(* Full-stack guy. ReactJS, Rails, TDD. Best OODA loop wins)
24. Templating languages have a cost: they make building user
interfaces harder. Doing something simple like alternating row
colors in a table requires jumping through hoops in many languages.
!
What we should do instead is accept that user interfaces are becoming
more and more complicated and that we need a real programming
language (with all of its expressive power) to build user interfaces at
scale.
!
(With React) instead of an oversimplified templating language, you
get to use JavaScript to build abstractions and reuse code.
— Pete Hunt
37. Composition
var PictureOfTheDay = require('./Components/PictureOfTheDay.js');!
var DateBrowser = require('./Components/DateBrowser.js');!
var Title = require('./Components/Title.js');!
!
var SpacePics = React.createClass ({!
render() {!
return (!
<div>!
<Title title={this.state.title} />!
<PictureOfTheDay picture={this.state.picture} />!
<DateBrowser date={this.state.date} onChange={this._onDateChange} />!
</div>!
);!
38. require()
var PictureOfTheDay = require('./Components/PictureOfTheDay.js');!
var DateBrowser = require('./Components/DateBrowser.js');!
var Title = require('./Components/Title.js');!
!
var SpacePics = React.createClass ({!
render() {!
return (!
<div>!
<Title title={this.state.title} />!
<PictureOfTheDay picture={this.state.picture} />!
<DateBrowser date={this.state.date} onChange={this._onDateChange} />!
</div>!
);!
39. Passing data to children
var PictureOfTheDay = require('./Components/PictureOfTheDay.js');!
var DateBrowser = require('./Components/DateBrowser.js');!
var Title = require('./Components/Title.js');!
!
var SpacePics = React.createClass ({!
render() {!
return (!
<div>!
<Title title={this.state.title} />!
<PictureOfTheDay picture={this.state.picture} />!
<DateBrowser date={this.state.date} onChange={this._onDateChange} />!
</div>!
);!
75. // if we have an error
if (this.state.error !== null) {
innerNode = <ErrorWidget title="NASA
API Error" message={this.state.error} />;
title = 'Error';
}
If Error
79. Loading
// if we don't have a picture
else if (this.state.picture === null) {
innerNode = <Loading title="Getting
Image..." />;
title = 'Loading...';
}!