“React Redux Cheat” Kod odpowiedzi

React Redux Cheat

// 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
  }
}
Proud Piranha

React Redux Cheat

// Optional - you can pass `initialState` as a second arg
let store = createStore(counter, { value: 0 })
Proud Piranha

React Redux Cheat

import { createStore } from 'redux'
Proud Piranha

React Redux Cheat

let store = createStore(counter)
Proud Piranha

React Redux Cheat

// Gets the current state
store.getState()
Proud Piranha

Odpowiedzi podobne do “React Redux Cheat”

Pytania podobne do “React Redux Cheat”

Więcej pokrewnych odpowiedzi na “React Redux Cheat” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu