redux toolkit cheat sheet code example
Example 1: react redux cheat sheet
store.dispatch({ type: 'INCREMENT' })
store.dispatch({ type: 'DECREMENT' })
Example 2: react redux cheat sheet
function counter (state = { value: 0 }, action) {
switch (action.type) {
case 'INCREMENT':
return { value: state.value + 1 }
case 'DECREMENT':
return { value: state.value - 1 }
default:
return state
}
}
Example 3: react redux cheat sheet
import { createStore } from 'redux'
Example 4: react redux cheat sheet
store.getState()