<body>
11212
<script src="./index.js"></script>
<script src="./data.js"></script>
</body>
const INCREMENT ='INCREMENT' ; // define a constant for increment action types
const DECREMENT = 'DECREMENT'; // define a constant for decrement action types
const counterReducer = (state=0,action)=>{
switch(action.type) {
case INCREMENT:
let newState=state+ 1
console.log(newState)
return state+= 1;
break;
case DECREMENT:
let newStateDec=state- 1
console.log(newStateDec)
return state-= 1;
break;
default:
return state;
}
}; // define the counter reducer which will increment or decrement the state based on the action it receives
const incAction = ()=>{
return {
type:INCREMENT
}
}; // define an action creator for incrementing
const decAction = ()=>{
return {
type:DECREMENT
}
}; // define an action creator for decrementing
const store = Redux.createStore(counterReducer); // define the Redux store here, passing in your reducers
store.dispatch(incAction())
store.dispatch(incAction())
store.dispatch(incAction())
store.dispatch(decAction())
store.dispatch(decAction())