“React Redux Cheat Sheet” Kode Jawaban

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

React Redux Cheat Sheet

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

React Redux Cheat Sheet

import { createStore } from 'redux'
Proud Piranha

React Redux Cheat Sheet

let store = createStore(counter)
Proud Piranha

React Redux Cheat Sheet

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

Jawaban yang mirip dengan “React Redux Cheat Sheet”

Pertanyaan yang mirip dengan “React Redux Cheat Sheet”

Lebih banyak jawaban terkait untuk “React Redux Cheat Sheet” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya