Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { createStore } from 'redux';
- const increment = () => ({
- type: 'INCREMENT',
- });
- const decrement = () => ({
- type: 'DECREMENT',
- });
- function counter(state = 0, action) {
- switch (action.type) {
- case 'INCREMENT':
- return state + 1;
- case 'DECREMENT':
- return state - 1;
- default:
- return state;
- }
- }
- const store = createStore(counter);
- store.subscribe(() => console.log(store.getState()));
- store.dispatch(increment());
- store.dispatch(decrement())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement