This file contains 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
{ | |
"AF": "Afghanistan", | |
"AX": "Aland Islands", | |
"AL": "Albania", | |
"DZ": "Algeria", | |
"AS": "American Samoa", | |
"AD": "Andorra", | |
"AO": "Angola", | |
"AI": "Anguilla", | |
"AQ": "Antarctica", |
This file contains 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
// we create a Memoized functional component here, notice React.memo() | |
const SimpleFormField = React.memo(({ name, value, onUpdate }) => { | |
return <input type="text" value={value} name={name} onChange={onUpdate} /> | |
}) | |
const SimpleForm = () => { | |
const [{ name, address }, setFormState] = useState({ name: '', address: '' }); | |
const handleSubmit = (ev) => { | |
ev.preventDefault(); |
This file contains 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
const SimpleForm = ({ onSubmit }) => { | |
// We use useState hook to store the forms data | |
const [formState, setFormState] = useState({ | |
name: '', | |
address: '', | |
pet: '', | |
}); | |
// a function to handle the form submission | |
const handleSubmit = (ev) => { |
This file contains 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
const _isArray = Array.isArray, { | |
slice: _slice, | |
includes: _includes, | |
concat: _concat, | |
sort: _sort, | |
filter: _filter, | |
reduce: _reduce, | |
map: _map, | |
} = Array.prototype |
This file contains 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
"use strict"; | |
// A function that wraps a given `React.DOM.input`-like component to | |
// apply formatting to the value for display purposes. | |
// | |
// Example: | |
// | |
// var RoundedInput = createFormattedInput(React.DOM.input, { | |
// set: Math.round, | |
// }); |
This file contains 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
var externals = require('./package.json').dependencies; | |
gulp.task('modules', function () { | |
var bs = browserify(); | |
for (var k in externals) { | |
bs.require(k); | |
} | |
bs.transform(debowerify) |
This file contains 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
module['exports'] = App.createComponent('VoteSpinner', { | |
getInitialState: function () { | |
return { | |
vote: 0, | |
busy: false | |
}; | |
}, | |
toggle: function (val) { |
This file contains 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
var MyList = React.createClass({ | |
componentWillMount: function () { | |
this.setState({ | |
itemsDataContract: dataService.get('/api/items', {take: 10}) // returns a object describing the state of the request, not the actual data | |
}); | |
} | |
render: function () { | |
var contract = this.state.itemsDataContract; |
This file contains 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
var CommentBox = React.createClass({ | |
render: function() { | |
return ( | |
<div className="commentBox"> | |
<h1>Comments</h1> | |
<CommentList /> | |
<CommentForm /> | |
</div> | |
); | |
} |
This file contains 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
define({ | |
load: function (name, req, load, config) { | |
var n, k, names = name.split(','), | |
len = names.length, | |
loaded = {}, | |
count = 0; | |
function subload(n, key) { | |
req([n], function (val) { | |
loaded[key] = val; |
NewerOlder