DeveloperBreeze

Tutorials Programming Tutorials, Guides & Best Practices

Explore 149+ expertly crafted tutorials tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Building a Modern Web Application with React and Redux

Tutorial August 05, 2024
javascript

In the src directory, create a new file called store.js and add the following code:

   import { createStore } from 'redux';

   const initialState = {
     count: 0,
   };

   const reducer = (state = initialState, action) => {
     switch (action.type) {
       case 'INCREMENT':
         return { ...state, count: state.count + 1 };
       case 'DECREMENT':
         return { ...state, count: state.count - 1 };
       default:
         return state;
     }
   };

   const store = createStore(reducer);

   export default store;