All Things Open 2014 - Day 2
Thursday, October 23rd, 2014
James Pearce
Head of Open Source with Facebook
Front Dev 1
An Introduction to ReactJS
Find more by James here: https://speakerdeck.com/jamesgpearce
21. props
!
passed in from parent
!
<MyComp foo="bar" />
this.props read-only within
!
can be defaulted & validated
state
!
created within component
!
getInitialState
this.state to read
this.setState() to update
22. var MyComponent = React.createClass({
!
propTypes: {},
getDefaultProps: function () {},
getInitialState: function () {},
!
componentWillMount: function () {},
componentWillUnmount: function () {},
...
render: function () {
// only read props & state -> return UI
},
});
23. var MyComponent = React.createClass({
!
iGotClicked: function () {...},
!
render: function () {
return <div onClick={this.iGotClicked}>Click</div>;
},
});
Or a parent’s method passed in via props
32. Table
Row Cell Cell Cell Cell
Row Cell Cell Cell Cell
Row Cell Cell Cell Cell
state is
on cells
33. Table
Row Cell Cell Cell Cell
Row Cell Cell Cell Cell
Row Cell Cell Cell Cell
Total
Total
Total
state is
on rows
34. Table
Row Cell Cell Cell Cell
Row Cell Cell Cell Cell
Row Cell Cell Cell Cell
Total
Total
Total
Row Total Total Total Total Total
state is
on table