react redux cheat sheet
// Dispatches an action; this changes the state
store.dispatch({ type: 'INCREMENT' })
store.dispatch({ type: 'DECREMENT' })
react redux cheat sheet
// Dispatches an action; this changes the state
store.dispatch({ type: 'INCREMENT' })
store.dispatch({ type: 'DECREMENT' })
react redux cheat sheet
// Gets the current state
store.getState()
react redux cheat sheet
import { createStore } from 'redux'
react redux cheat sheet
// Optional - you can pass `initialState` as a second arg
let store = createStore(counter, { value: 0 })
react redux cheat sheet
// Reducer
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
}
}
react redux cheat sheet
let store = createStore(counter)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us