Skip to content

Instantly share code, notes, and snippets.

@hedgerh
hedgerh / .babelrc
Last active November 4, 2015 02:53
{
"stage": 0,
"env": {
"development": {
"plugins": ["react-transform"],
"extra": {
"react-transform": {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
const ADD_TO_CART = 'ADD_TO_CART';
const CHECKOUT_REQUEST = 'CHECKOUT_REQUEST';
export function addToCart(productId) {
return {
type: ADD_TO_CART,
productId
}
}
import request from 'superagent';
const RECEIVE_PRODUCTS = 'RECEIVE_PRODUCTS';
export function getAllProducts() {
return dispatch => {
request.get('/products')
.set('Content-Type', 'application/json')
.end((err, res) => {
if (err) {
return new Error(err);
{
"addPost" { children: ["completed", "failure"] }
}
// in your store
onAddPost(),
onAddPostCompleted(),
onAddPostFailure()
render() {
return (
<div>
<button onClick={ this.updatePost }>Update</button>
</div>
);
};
updatePost(e) {
@hedgerh
hedgerh / a
Created October 11, 2015 10:01
https://ohthehugemanatee.org/blog/2015/10/01/how-i-got-el-capitain-working-with-my-developer-tools/
@hedgerh
hedgerh / Enhance.js
Last active August 27, 2015 18:24 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = (ComposedComponent, ajaxCall) => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
ajaxCall()
.then(function(data) {
this.setState({ data: data });
@hedgerh
hedgerh / README.md
Last active April 1, 2017 22:22
Build Gitbooks for each Git tag of a repository.

Setup:

Set permissions to allow script to run

chmod a+x ./gitbook-tag-build.sh

Usage:

Choose an output folder, and an input file containing a list of Git tags.

The default ouput folder is _allBooks and the default input is .gitbook-tags

import React from 'react';
import { Router } from 'react-router';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import App from '../shared/containers/App';
import todoApp from '../shared/reducers';
import routes from '../shared/routes';
import immutifyState from '../shared/lib/immutifyState';
const initialState = immutifyState(window.__INITIAL_STATE__);