Skip to content

Instantly share code, notes, and snippets.

@DveMac
DveMac / ISO3166-1.alpha2.json
Created September 24, 2021 09:05 — forked from ssskip/ISO3166-1.alpha2.json
json of country codes (ISO 3166-1 alpha-2) and corresponding names
{
"AF": "Afghanistan",
"AX": "Aland Islands",
"AL": "Albania",
"DZ": "Algeria",
"AS": "American Samoa",
"AD": "Andorra",
"AO": "Angola",
"AI": "Anguilla",
"AQ": "Antarctica",
// 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();
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) => {
const _isArray = Array.isArray, {
slice: _slice,
includes: _includes,
concat: _concat,
sort: _sort,
filter: _filter,
reduce: _reduce,
map: _map,
} = Array.prototype
"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,
// });
var externals = require('./package.json').dependencies;
gulp.task('modules', function () {
var bs = browserify();
for (var k in externals) {
bs.require(k);
}
bs.transform(debowerify)
module['exports'] = App.createComponent('VoteSpinner', {
getInitialState: function () {
return {
vote: 0,
busy: false
};
},
toggle: function (val) {
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;
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
<h1>Comments</h1>
<CommentList />
<CommentForm />
</div>
);
}
@DveMac
DveMac / hash.js
Created July 13, 2012 11:35
Require.js plugin to load multiple modules as a single object
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;