Skip to content

Instantly share code, notes, and snippets.

View vm137's full-sized avatar
💭
Java minded

Victor Mikhaylov vm137

💭
Java minded
View GitHub Profile
@borisd
borisd / example.js
Created April 20, 2017 00:36
Simple Redux Implementation
const reducer = (state, action) => action.type == 'INC'
? Object.assign({}, state, { counter: state.counter + 1 })
: state;
const store = createStore(reducer, { counter: 1 });
const unsubscribe = store.subscribe(() => console.log('Counter: ' + store.getState().counter));
store.dispatch({ type: 'INC' })
store.dispatch({ type: 'INC' })
@borisd
borisd / connect.js
Created May 1, 2016 16:05
A super simple redux connect() implementation
import store from 'store/store';
const connect = (mapStateToProps) => (Component) => {
class Connect extends React.Component {
constructor() {
super();
this.state = {};
}
componentDidMount() {