Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const INCREMENT = 'INCREMENT';
- const DECREMENT = 'DECREMENT';
- const counterReducer = (state = 0, action) => { //A reducer function to add/sub counter
- switch(action.type) {
- case INCREMENT:
- return state + 1;
- case DECREMENT:
- return state - 1;
- default:
- return state;
- }
- };
- const LOGIN = 'LOGIN';
- const LOGOUT = 'LOGOUT';
- const authReducer = (state = {authenticated: false}, action) => { //A reducer function to authenticate
- switch(action.type) {
- case LOGIN:
- return {
- authenticated: true
- }
- case LOGOUT:
- return {
- authenticated: false
- }
- default:
- return state;
- }
- };
- const rootReducer = Redux.combineReducers({ //this combines the individual reducer functions into a root function that has the keys, and then the other reducer functions assiciated with that key.
- count: counterReducer,
- auth: authReducer
- });
- const store = Redux.createStore(rootReducer);
Add Comment
Please, Sign In to add comment