Skip to content

Instantly share code, notes, and snippets.

@jackcallister
jackcallister / App.jsx
Created September 6, 2015 17:13
Redux Router Reducer
import {
updateRouterState
} from '../actions/RouterActions';
function mapStateToProps(store) {
return {}
}
function mapDispatchToProps(dispatch) {
return {
// The Redux Store
{
posts : [{
...stuff,
userId: 1
tagIds: [1,2,3]
}],
users: [{
...stuff,
import { createAction } from 'redux-actions';
import * as WebUtils from '../webUtils/index';
import {
SELECT_MEAL,
UPDATE_MEAL_PROP,
BEGIN_CREATING_MEAL,
SUCCESS_CREATING_MEAL,
ERROR_CREATING_MEAL,
BEGIN_LOADING_MEALS,
import Flux from './Flux.js'
import Flux from './components/App.jsx'
// Within document ready
const payload = document.getElementById('payload');
const flux = new AppFlux();
flux.serialize(payload);
import 'babel/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route } from 'react-router';
import { reduxRouteComponent, routerStateReducer } from 'redux-react-router';
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import BrowserHistory from 'react-router/lib/BrowserHistory';
import routes from '../shared/components/routes';
import * as reducers from '../shared/reducers/index';
// WebUtils
WebUtils = {
fetchMe: function(opts) {
return new Promise(function(resolve, reject) {
request.get(`${SOUNDCLOUD_URL}/me`)
.query(opts)
.end((err, res) => { me: res.body });
}
});
}
@jackcallister
jackcallister / react.js
Created February 13, 2015 01:43
React Object
var React = {
Children: {
map: ReactChildren.map,
forEach: ReactChildren.forEach,
count: ReactChildren.count,
only: onlyChild
},
Component: ReactComponent,
DOM: ReactDOM,
@jackcallister
jackcallister / package.json
Created February 10, 2015 05:58
Run parallel tasks
"scripts": {
"start": "npm run webpack & npm run serve",
"webpack": "webpack -w",
"serve": "cd example && python -m SimpleHTTPServer"
}
@jackcallister
jackcallister / index.html
Created December 25, 2014 09:14
React JS quick start guide // source http://jsbin.com/rohin
<!DOCTYPE html>
<html>
<head>
<script src="http://fb.me/react-with-addons-0.12.0.js"></script>
<meta charset="utf-8">
<title>React JS quick start guide</title>
<style id="jsbin-css">
body {
margin: 0;
background: #E8E8E8;
// 1. Components load for the first time.
// 2. An action causes the node to be removed.
// 1. Element will enter the DOM
componentWillEnter: function(callback) {
callback();
console.log('will enter');
},
// // 1. Element is now in the DOM