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:
// Ok: | |
this.stateModel.on('change:readMore', this.renderReadMore, this); | |
// Awesome: | |
this.listenTo(this.stateModel, 'change:readMore', this.renderReadMore); |
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; | |
} |
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, |
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({ |
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 { |
const consumer = dependency => dependency.doSomething(); | |
const realDependency = { | |
doSomething () { | |
console.log('did something!'); | |
} | |
}; | |
consumer(realDependency); |
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 ] |
Moved to: http://github.com/gf3/dotfiles/blob/master/bash_prompt |
<!-- Highlight syntax for Mou.app, insert at the bottom of the markdown document --> | |
<script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script> | |
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/github.min.css"> | |
<script> | |
hljs.initHighlightingOnLoad(); | |
</script> |