Photo by Florencia Viadana on Unsplash
const incrementBy1Action = {
type: 'count/incrementBy1'
}
counterReducer(state, action) => newState 
function counterReducer( state = {count: 0}, action ) {
if (action.type === 'count/incrementBy1') {
return { ...state, count: state.count + 1 }
}
return state
}
import { configureStore } from '@reduxjs/toolkit'const store = configureStore({ reducer: counterReducer })
console.log(store.getState())
// { count : 0 }
store.dispatch({ type: 'count/incrementBy1' })console.log(store.getState())
// { count : 1 }

Software Engineer and Brazilian Jiu-Jitsu brown belt

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store