This file contains hidden or 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 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' }) |
This file contains hidden or 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 store from 'store/store'; | |
const connect = (mapStateToProps) => (Component) => { | |
class Connect extends React.Component { | |
constructor() { | |
super(); | |
this.state = {}; | |
} | |
componentDidMount() { |