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
| import React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| // Instead of using a HOC, we can share code using a | |
| // regular component with a render prop! | |
| class Mouse extends React.Component { | |
| static propTypes = { | |
| render: PropTypes.func.isRequired, | |
| }; | |
| state = { x: 0, y: 0 }; |
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
| # enable ES6 | |
| parserOptions: | |
| ecmaVersion: 6 | |
| sourceType: "module" | |
| ecmaFeatures: | |
| jsx: true # enable React's JSX | |
| # register plugins | |
| plugins: | |
| - meteor |
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
| { | |
| "name": "project", | |
| "private": true, | |
| "scripts": { | |
| "test": "tape 'tests/unit/**/*.js'" | |
| }, | |
| "devDependencies": { | |
| "tape": "4.2.2" | |
| } | |
| } |
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
| // ES6 | |
| class Tweet { | |
| constructor (doc) { | |
| _.extend(this, doc); | |
| } | |
| } | |
| Tweets = new Mongo.Collection('tweets', { | |
| transform (doc) { | |
| return new Tweet(doc); |
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
| // ES6 | |
| Template.lead.helpers({ | |
| twitterLink () { | |
| return this.getTwitterLink(); | |
| }, | |
| weekday (timestamp) { | |
| return moment(timestamp).format(‘dddd’); | |
| } | |
| }); |
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
| // ES6 | |
| UI.registerHelper('sum', function (...summands) { | |
| summands.pop(); // remove last argument hash (Spacebars.kw) | |
| return summands.reduce((previousValue, currentValue) => { | |
| return previousValue + currentValue; | |
| }); | |
| }); |
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
| // ES5 | |
| UI.registerHelper('sum', function (/* arguments */) { | |
| var summands = Array.prototype.slice.call(arguments); | |
| summands.pop(); // remove last argument hash (Spacebars.kw) | |
| var sum = 0; | |
| for (var i = 0; i < summands.length; i++) { | |
| sum += summands[i]; | |
| } | |
| return sum; | |
| }); |
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
| // ES6 | |
| const versionsMap = new Map(); | |
| lines.forEach( line => versionsMap.set(...line.split(‘@’)) ); |
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
| // ES6 | |
| const versionsMap = new Map(); | |
| lines.forEach((line) => { | |
| const [name, version] = line.split(‘@’); // destructuring | |
| versionsMap.set(name, version); | |
| }); |