第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

React Redux 狀態(tài)對象屬性

React Redux 狀態(tài)對象屬性

九州編程 2021-06-16 18:19:30
我想知道為什么我的狀態(tài) todos在 redux 開發(fā)工具中命名為todo而不是todos .. 這個名字是從哪里來的?沒有初始狀態(tài)..我想知道..我正在關(guān)注Stephen Grider udemy 課程,但使用待辦事項而不是流作為修訂為什么我必須回到它state.todo不state.todos?Jsson 服務(wù)器 db.json 文件(api 文件)        {      "todos": [        {          "title": "lorem ipsum ",          "description": "lorem ipsum",          "id": 4        }      ]    }todoReducer.js        import _ from 'lodash';    import {      CREATE_TODO,      EDIT_TODO,      FETCH_TODO,      FETCH_TODOS,      DELETE_TODO    } from '../actions/types';    export default (state = {}, action) => {      switch (action.type) {        case FETCH_TODOS:          return { ...state, ..._.mapKeys(action.payload, 'id') };        case CREATE_TODO:        case FETCH_TODO:        case EDIT_TODO:          return { ...state, [action.payload.id]: action.payload };        case DELETE_TODO:          return _.omit(state, action.payload);        default:          return state;      }    };動作/ index.js        import todos from '../apis/todos';    import history from '../history';    import {      SIGN_IN,      SIGN_OUT,      CREATE_TODO,      EDIT_TODO,      FETCH_TODO,      FETCH_TODOS,      DELETE_TODO    } from './types';    export const signIn = userId => {      return { type: SIGN_IN, payload: userId };    };    export const signOut = () => {      return { type: SIGN_OUT };    };    export const fetchTodos = () => async dispatch => {      const response = await todos.get('/todos');      dispatch({ type: FETCH_TODOS, payload: response.data });    };    export const createTodo = formValues => async dispatch => {      const response = await todos.post('/todos', formValues);      dispatch({ type: CREATE_TODO, payload: response.data });      history.push('/');    };
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號