Skip to content

Instantly share code, notes, and snippets.

View invegat's full-sized avatar

Mark Oliver invegat

View GitHub Profile
@gaearon
gaearon / actionsactionsactionsactions.js
Created June 16, 2015 12:06
Basic action monitoring for Redux
// App.js
import { Provider, Connector } from 'redux/react';
import monitor from './monitor/index';
const store = composeStores(stores);
const { dispatcher, ActionLog } = monitor(createDispatcher(store));
const redux = createRedux(dispatcher);
export default class App {
@gaearon
gaearon / ReduxMicroBoilerplate.js
Last active March 26, 2020 00:35
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
@gaearon
gaearon / ReduxUndoExample.js
Created July 30, 2015 14:46
Redux undo reducer factory example by @iclanzan
// Written by @iclanzan
// All credit goes to him!
// You create the reducer like this:
// var reducer = createTimelineReducer('someName', someReducer, ['foo', 'bar']);
// And then whenever an action of type `foo` or `bar` happens it calls `someReducer` and adds the result to the timeline.
// Then to undo/redo you trigger an action of type `someNameUndo`/`someNameRedo`.
var defaults = require('lodash/object/defaults');
var capitalize = require('lodash/string/capitalize');
@gaearon
gaearon / reducers.js
Last active December 11, 2020 14:56
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
@gaearon
gaearon / a.js
Created May 20, 2016 20:15
Basic HMR
// change this file
module.exports = 42