{"size": 980, "ext": "js", "max_stars_repo_path": "src/store.js", "max_stars_repo_name": "euguilhermegirardi/Redux-Hooks-Intro", "max_stars_repo_stars_event_min_datetime": "2020-06-05T16:25:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-05T16:25:01.000Z", "max_issues_repo_path": "src/store.js", "max_issues_repo_name": "euguilhermegirardi/Redux-Intro", "max_issues_repo_issues_event_min_datetime": "2021-10-06T18:10:42.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T06:04:11.000Z", "max_forks_repo_path": "src/store.js", "max_forks_repo_name": "euguilhermegirardi/Redux-Hooks-Intro", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 23.3333333333, "max_line_length": 101, "alphanum_fraction": 0.6346938776}
import { createStore, combineReducers, applyMiddleware } from 'redux';
// applyMiddleware = function the intercept every single action that we create using dispatch method.
import logger from 'redux-logger';

function counterReducer(state = 0, action) {
  if (action.type === 'INCREMENT') {
    return state + 1;
  }

  if (action.type === 'DECREMENT') {
    return state - 1;
  }

  return state;
};

// function todosReducer(state = [], action) {
//   switch(action.type) {
//     case 'CREATE_TODO':
//       return state.concat([action.payload]);

//     case 'DELETE_TODO':
//       return state.filter((item, index) => index !== action.id);

//     case 'UPDATE_TODO':
//       return state.map((item, index) => index === action.id ? action.payload : item );

//     default:
//       return state;
//   }
// };

const store = createStore(
  combineReducers({
    // todos: todosReducer,
    counter: counterReducer
  }),
  applyMiddleware(logger)
);

export default store;
