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
/* defintion */ | |
const createErrorClass = (name, customConstructor = () => {}) => { | |
const ctx = { | |
[name]: class extends Error { | |
constructor(...args) { | |
super(name); | |
customConstructor(this, ...args); | |
Error.captureStackTrace(this, ctx[name]); | |
} | |
} |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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 SimpleTextInput extend Component { | |
state = { | |
value: this.props.value, | |
}; | |
componentWillReceiveProps(nextProps) { | |
if (this.props.value !== nextProps.value) { | |
this.setState({value: nextProps.value}); | |
} | |
} | |
render() { |
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
/* | |
* Types for React Router V4 | |
* Example Usage: | |
* type PropsT = { | |
* myProp: string, | |
* } & ContextRouterT<{ | |
* routeParam: string, | |
* anotherRouteParam: ?string, | |
* }> | |
*/ |
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
_.mixin({ | |
enzyme: reactWrapper => ( | |
new Proxy(reactWrapper, { | |
get: (wrapper, prop) => { | |
const isSymbol = typeof prop === 'symbol'; | |
const isNumber = !isSymbol && !isNaN(Number(prop)); | |
return isNumber ? wrapper.at(prop) : wrapper[prop]; | |
}, | |
}) |
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
git config --global alias.ci 'commit'; | |
git config --global alias.st 'status'; | |
git config --global alias.br 'branch'; | |
git config --global alias.unstage 'reset HEAD --'; | |
git config --global alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'; | |
git config --global alias.type 'cat-file -t'; | |
git config --global alias.dump 'cat-file -p'; | |
git config --global alias.tree 'log --all --graph --decorate --oneline --simplify-by-decoration'; | |
git config --global alias.als 'config --get-regexp alias'; | |
git config --global alias.clog 'log --pretty=oneline --abbrev-commit'; |
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 { createStore, combineReducers } from 'redux'; | |
const reduceReducers = (reducers) => (state, action) => | |
reducers.reduce((result, reducer) => ( | |
reducer(result, action) | |
), state); | |
export const storeManager = { | |
store: null, | |
reducerMap: {}, |
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
// AppContainer.js | |
import {withRefreshedStore} from 'react-store-manager'; | |
const HomeRoute = Loadable({ | |
loader: withRefreshedStore(import('./HomePageContainer')), | |
loading: () => <div>Loading...</div> | |
}); | |
const ProductListRoute = Loadable({ | |
loader: withRefreshedStore(import('./ProductListPageContainer')), |
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
Root.js | |
|_AppContainer.js | |
|_App.js | |
|_loginReducer.js | |
|_PageContainer.js | |
|_Page.js | |
|_pageReducer.js |
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
// HomePageContainer.js | |
import storeManager from 'react-store-manager'; | |
import homeReducer from './homeReducer'; | |
storeManager.registerReducers({ home: homeReducer }); | |
export default connect(/* mapStateToProps, mapDispatchToProps */)(Page); | |
// ProductListPageContainer.js | |
import storeManager from 'react-store-manager'; |
NewerOlder