Last active
January 4, 2016 21:39
-
-
Save jordwalke/8682861 to your computer and use it in GitHub Desktop.
React JavaScript: Just Like You've Always Done It (with arrow funcs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ReactJS: JavaScript like you've always done it. | |
* | |
* This example renders your top ten most followed friends/followers, `filter`ing | |
* only your favorites, and putting a star on all verified accounts. | |
* | |
* With ReactJS, any time your data changes, the UI is always brought up to date | |
* automatically. If friends length changes, or followCount - it always shows what | |
* `render` describes. | |
*/ | |
var PeopleList = React.createClass({ | |
render: () => | |
<div className="list">{ | |
{this.props.friends.concat(this.props.followers) | |
.filter(person => person.isFavorite) | |
.sort((one, two) => one.followCount - two.followCount) | |
.slice(0, 10) | |
.map(person => | |
<div className={person.verified ? 'star' : ''}>{person.name}</div> | |
) | |
} | |
</div>; | |
}); | |
/** | |
* Instead of making you set up "Bindings" to models: | |
* - React uses plain JavaScript *functions* to bind outputs to inputs. | |
* | |
* Instead of making you set up "computed values": | |
* - React uses plain JavaScript *expressions* to compute values. | |
* | |
* Instead of making you use "collections": | |
* - React uses plain JavaSctript *Arrays* to model changing lists. | |
* | |
* - Just functions. | |
* - Just expressions. | |
* - Just plain Arrays and Objects. | |
* - React JavaScript: Just like you've always done it. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment