react redux cheat sheet

Solutions on MaxInterview for react redux cheat sheet by the best coders in the world

showing results for - "react redux cheat sheet"
Mira
15 Nov 2019
1// Dispatches an action; this changes the state
2store.dispatch({ type: 'INCREMENT' })
3store.dispatch({ type: 'DECREMENT' })
4
Francesco
03 Mar 2019
1let store = createStore(counter)
2
Vincenzo
28 Nov 2019
1// Gets the current state
2store.getState()
3
Francesca
18 May 2016
1import { createStore } from 'redux'
2
Maja
12 Mar 2019
1// Optional - you can pass `initialState` as a second arg
2let store = createStore(counter, { value: 0 })
3
Federica
07 Mar 2019
1// Reducer
2function counter (state = { value: 0 }, action) {
3  switch (action.type) {
4  case 'INCREMENT':
5    return { value: state.value + 1 }
6  case 'DECREMENT':
7    return { value: state.value - 1 }
8  default:
9    return state
10  }
11}
12