This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DumbComponent = (props) => { | |
return (<div />); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Container extends React.Component { | |
render(){ | |
const { props } = this; | |
return( | |
<div className="main-content"> | |
{ | |
React.Children.map(this.props.children, function(child) { | |
return React.cloneElement( | |
child, | |
{ ...props } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* getStockValue() { | |
var entry1 = yield request('http://myrl.com/stock/key'); | |
var data1 = JSON.parse(entry1); | |
var entry2 = yield request('http://myurl/stock/value'); | |
var data2 = JSON.parse(entry2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getJSON(url, function(response) { | |
getJSON(url, function(response) { | |
console.log(response); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createConstants(...constants) { | |
return constants.reduce((acc, constant) => { | |
acc[constant] = constant; | |
return acc; | |
}, {}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createReducer(initialState, reducerMap) { | |
return (state = initialState, action) => { | |
const reducer = reducerMap[action.type]; | |
return reducer | |
? reducer(state, action.payload) | |
: state; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {createReducer} from '../../utils'; | |
// Add the following for IE compatability | |
Object.assign = Object.assign || require('object-assign'); | |
const initialState = { | |
'count': 0, | |
'receiving': false, | |
'pages': 0, | |
'documents': [] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isObjectEqual = (obj1, obj2) => { | |
if(!isObject(obj1) || !isObject(obj2)) { | |
return false; | |
} | |
if (obj1 === obj2) { | |
return true; | |
} | |
const item1Keys = Object.keys(obj1).sort(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const isFunction = input => typeof input === 'function'; | |
export default predicate => elemOrThunk => | |
predicate ? (isFunction(elemOrThunk) ? elemOrThunk() : elemOrThunk) : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import renderIf from '../utils/renderif' | |
export default class RenderIfExample extends Component { | |
render() { | |
var isTrue = true; | |
return ( | |
<div> | |
{renderIf(isTrue)( | |
<h1>I am being rendered</h1> |
OlderNewer