Skip to content

Instantly share code, notes, and snippets.

View hunterc's full-sized avatar

Hunter Cassidy hunterc

View GitHub Profile
import React from 'react';
import { render } from 'react-dom';
import { createStore, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import { Router, Route, IndexRedirect } from 'react-router';
import { useBasename, createHistory } from 'history';
import { syncReduxAndRouter, routeReducer } from 'redux-simple-router';
const reducer = combineReducers({
routing: routeReducer
@hunterc
hunterc / esnextbin.md
Created June 1, 2016 13:02
esnextbin sketch
@hunterc
hunterc / async-examples.js
Created October 22, 2016 01:47 — forked from developit/async-examples.js
Async Array utilities in async/await. Now available as an npm package: https://github.com/developit/asyncro
/** Async version of Array.prototype.reduce()
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => {
* acc[v] = await (await fetch(v)).json();
* return acc;
* }, {});
*/
export async function reduce(arr, fn, val, pure) {
for (let i=0; i<arr.length; i++) {
let v = await fn(val, arr[i], i, arr);
if (pure!==false) val = v;
@hunterc
hunterc / Fetch.js
Created October 5, 2017 02:56
<Fetch> component
// @flow
import type { Element } from "react"
import React from "react"
import invariant from "invariant"
type State = {
data: Object | null,
error: Error | null,
fetching: boolean