Skip to content

Instantly share code, notes, and snippets.

Sagi Avinash Varma sagiavinash

Block or report user

Report or block sagiavinash

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sagiavinash
sagiavinash / SimpleTextInput_CWRP.js
Created Sep 12, 2018
SimpleTextInput with CWRP
View SimpleTextInput_CWRP.js
class SimpleTextInput extend Component {
state = {
value: this.props.value,
};
componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
this.setState({value: nextProps.value});
}
}
render() {
@sagiavinash
sagiavinash / ReactRouterV4FlowTypes.js
Created Sep 10, 2018
Flow Types for React Router V4
View ReactRouterV4FlowTypes.js
/*
* Types for React Router V4
* Example Usage:
* type PropsT = {
* myProp: string,
* } & ContextRouterT<{
* routeParam: string,
* anotherRouteParam: ?string,
* }>
*/
@sagiavinash
sagiavinash / makeEnzymeCollectionsLodashCompatible.js
Last active Sep 4, 2018
make enzyme collections lodash compatible
View makeEnzymeCollectionsLodashCompatible.js
_.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];
},
})
@sagiavinash
sagiavinash / gitaliases
Last active Sep 6, 2018
My Git Aliases
View gitaliases
alias.co checkout
alias.ci commit
alias.st status
alias.br branch
alias.unstage reset HEAD --
alias.hist log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
alias.type cat-file -t
alias.dump cat-file -p
alias.tree log --all --graph --decorate --oneline --simplify-by-decoration
alias.als config --get-regexp alias
View redux-store-manager.js
import { createStore, combineReducers } from 'redux';
const reduceReducers = (reducers) => (state, action) =>
reducers.reduce((result, reducer) => (
reducer(result, action)
), state);
export const storeManager = {
store: null,
reducerMap: {},
View ReactReduxOnDemandTarget.js
// 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')),
View SampleReactReduxdependencyTargetTree.js
Root.js
|_AppContainer.js
|_App.js
|_loginReducer.js
|_PageContainer.js
|_Page.js
|_pageReducer.js
View TargetReactReduxApp.jsx
// 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';
View TypicalStoreAndRootReducer.js
// rootReducer.js
export default combineReducers({
a: reducerA,
b: reducerB
});
// store.js
import rootReducer from './rootReducer';
export default createStore(rootReducer);
@sagiavinash
sagiavinash / ReactReduxDependencyTargetTree.js
Last active Jul 29, 2018
React Redux Dependency Target Tree
View ReactReduxDependencyTargetTree.js
RootComponent.js
|_AppContainer.js
|_App.js
|_loginReducer.js
|_PageContainer.js
|_Page.js
|_pageReducer.js
You can’t perform that action at this time.