You will get one of these:
Uncaught (in promise) TypeError: Cannot read property 'toUpperCase' of undefined(…)
ReactCompositeComponent.js:870 Uncaught TypeError: Cannot read property 'displayName' of undefined
if you try to:
const reducerDescription = { | |
[actions.GET_MATCHES]: (state, action) => ({ ...state, matchesLoading: true }), | |
[actions.GET_MATCHES_SUCCESS]: (state, action) => ({ | |
...state, | |
matchesLoading: false, | |
matchesError: null, | |
matches: action.payload | |
}), | |
[actions.GET_MATCHES_FAILURE]: (state, action) => ({ | |
...state, |
import { IAction } from '../types/redux.types'; | |
import { actionTypes as errorTypes, showError } from './errors.actions'; | |
interface IPayloadCreators { | |
request(...args: any[]): any; | |
success(...args: any[]): any; | |
failure?(errorMsg: string): any; | |
} | |
interface IActionCreator { |
var camelCase = require('lodash.camelcase'); | |
const {Map, Record, List} = require('immutable'); | |
class Todo extends Record({ description: null, completed: false }) { | |
toggle() { | |
return this.set('completed', !this.completed); | |
} | |
} | |
const InitialTodoApp = Record({ |
const original = [0,1,2,3]; | |
const copy = Object.assign([], original, { 2: 42 }); // [0,1,42,3] | |
console.log(original); | |
// [ 0, 1, 2, 3 ] | |
console.log(copy); | |
// [ 0, 1, 42, 3 ] |
const consumer = dependency => dependency.doSomething(); | |
const realDependency = { | |
doSomething () { | |
console.log('did something!'); | |
} | |
}; | |
consumer(realDependency); |
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/ | |
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch | |
// async function | |
async function fetchAsync () { | |
// await response of fetch call | |
let response = await fetch('https://api.github.com'); | |
// only proceed once promise is resolved | |
let data = await response.json(); | |
// only proceed once second promise is resolved |
alias accio=wget | |
alias avadaKedavra='rm -f' | |
alias imperio=sudo | |
alias priorIncantato='echo `history |tail -n2 |head -n1` | sed "s/[0-9]* //"' | |
alias stupefy='sleep 5' | |
alias wingardiumLeviosa=mv | |
alias sonorus='set -v' | |
alias quietus='set +v' |
function asyncFunc(e) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve(e), e * 1000); | |
}); | |
} | |
const arr = [1, 2, 3]; | |
let final = []; | |
function workMyCollection(arr) { |
function parseQuery(locationSearch) { | |
locationSearch = locationSearch.substring(1); // remove "?" at the beginning | |
var values = locationSearch.split('&'); | |
var queryObj = values.reduce(function (result, item) { | |
var parts = item.split('='); | |
result[decodeURIComponent(parts[0])] = parts[1]; | |
return result; | |
}, {}); | |
return queryObj; | |
} |