Instead of checks like:
if (value === null) {
throw new Error("missing value")
}
doSomethingThatNeedsValue(value)
I've recently ran into a pitfall of [React.memo()
][memo] that seems generally overlooked; skimming over the top results in Google just finds it mentioned in passing in a [React issue][regit], but not in the [FAQ] or API [overview][react-api], and not in the articles that set out to explain React.memo()
(at least the ones I looked at). The issue is specifically that nesting children defeats memoization, unless the children are just plain text. To give a simplified code example:
const Memoized = React.memo(({ children }) => (<div>{children}</div>));
// Won't ever re-render
<Memoized>bar</Memoized>
// Will re-render every time; the memoization does nothing
Quick guide on how to setup git signing. Information is aggregated from following sources:
When you download an archive of your Facebook account, Facebook includes photos and videos you've uploaded, but not photos and videos you're tagged in that were uploaded by other people. This is a script to automatically download those.
This requires Python 3.
// Main | |
function combineReducers(reducerDict) { | |
const _initialState = getInitialState(reducerDict); | |
return function(state = _initialState, action) { | |
return Object.keys(reducerDict).reduce((acc, curr) => { | |
let slice = reducerDict[curr](state[curr], action); | |
return { ...acc, [curr]: slice }; | |
}, state); | |
}; | |
} |
# !/bin/bash | |
FILES=`{ git diff --name-only HEAD; \ | |
git ls-files --others --exclude-standard; } \ | |
| grep '\.js$' \ | |
| grep -v '^.*exclude-folder.*$'` | |
node_modules/.bin/eslint $FILES -f table --color --quiet |
// Bonfire: Diff Two Arrays | |
// Author: @benschac | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays?solution=function%20diff(arr1%2C%20arr2)%20%7B%0A%20%20var%20check%20%3D%20arr1%3B%0A%20%20var%20checker%20%3D%20arr2%3B%0A%20%20%0A%20%20var%20filtered1%20%3D%20check.filter(function(el)%20%7B%0A%20%20%20%20%20%20%20if(checker.indexOf(el)%20%3D%3D%20-1)%20%7B%0A%20%20%20%20%20%20%20%20%20return%20el%3B%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%3B%0A%20%20%0A%20%20%20var%20filtered2%20%3D%20checker.filter(function(el)%20%7B%0A%20%20%20%20%20%20%20if(check.indexOf(el)%20%3D%3D%20-1)%20%7B%0A%20%20%20%20%20%20%20%20%20return%20el%3B%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%3B%0A%20%20%0A%20%20return%20filtered1.concat(filtered2)%3B%0A%7D%0A%0A%0A%0A%0Adiff(%5B1%2C%202%2C%203%2C%205%5D%2C%20%5B1%2C%202%2C%203%2C%204%2C%205%5D)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function diff(arr1, arr2) { | |
var check = arr1; | |
var checker = arr2; | |
var filtered1 = |
[alias] | |
co = checkout | |
cob = checkout -b | |
coo = !git fetch && git checkout | |
br = branch | |
brd = branch -d | |
brD = branch -D | |
merged = branch --merged | |
st = status | |
aa = add -A . |