Skip to content

Instantly share code, notes, and snippets.

View navgarcha's full-sized avatar

Nav Garcha navgarcha

View GitHub Profile
componentWillMount() {
this.props.requestPhotos();
}
import { takeLatest } from 'redux-saga';
import { PHOTOS_REQUEST } from 'actions/photos';
function* requestPhotos() {
// ...
}
export function* watchRequestPhotos() {
yield* takeLatest(PHOTOS_REQUEST, requestPhotos);
}
function requestContextData(store = {}, { components = [] }) {
const promises = components.reduce((prev, current = {}) => {
return (current.need || []).concat(prev);
}, []).map((need) => store.dispatch(need()));
return Promise.all(promises);
}
// ...
import { requestPosts } from 'actions/posts';
// ..
static need = [
() => requestPosts()
]
componentDidMount() {
if (!this.props.posts) {
.broken{background-size:100%;background-image:-webkit-gradient(linear,0 50%,100% 50%,color-stop(0%,#000),color-stop(100%,#fff));background-image:-webkit-linear-gradient(left,#000,#fff);background-image:-moz-linear-gradient(left,#000,#fff);background-image:-o-linear-gradient(left,#000,#fff);background-image:linear-gradient(left,#000,#fff)}
.working{background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iNTAlIiB4Mj0iMTAwJSIgeTI9IjUwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==);background:-webkit-gradient(linear,0 50%,100% 50%,color-stop(0%,#000),color-stop(100%,#fff));background:-webkit-linear-gradient(left,#0