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
// https://medium.com/javascript-inside/safely-accessing-deeply-nested-values-in-javascript-99bf72a0855a | |
const idx = p => o => | |
p.reduce((xs, x) => | |
(xs && xs[x]) ? xs[x] : null, o) | |
const getUserComments = idx(['posts', 0, 'comments']) | |
const user = {} | |
console.log(getUserComments(user)) |
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
window.__testCleanup = () => { | |
const unregisterSW = () => { | |
return navigator.serviceWorker.getRegistrations() | |
.then((registrations) => { | |
const unregisterPromise = registrations.map((registration) => { | |
return registration.unregister(); | |
}); | |
return Promise.all(unregisterPromise); | |
}); | |
}; |
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
import React from 'react'; | |
/** | |
* Server only Provider component that passes promises as context | |
*/ | |
export default class ServerFetchProvider extends React.Component { | |
static childContextTypes = { | |
serverFetchPromises: React.PropTypes.array | |
}; | |
static propTypes = { |
NewerOlder