EggHead React Cheatsheet
2020-02-27 148浏览
- 1.Redux Cheat Sheet (3.2.1) import React from 'react' import ReactDOM from 'react-dom' import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux' const greetingReducer = (state='' , action) => { switch (action.type) { case 'SAY_HELLO': return 'Hello ' case 'SAY_GOODBYE': return 'Goodbye ' } return state } const nameReducer = (state='John', action) => { switch (action.type) { case 'CHANGE_NAME': return 'Joel' } return state } const actionLogger = ({dispatch, getState}) => (next) => (action) => { console.log(action); return next(action) } const reducers = combineReducers({greeting:'>greeting: