簡體   English   中英

學習Redux,這是否違反任何國家負責人?

[英]Learning Redux, does this violate any state principals?

我有一個axios調用,用於DELETE和POST我的api,在調用完成后它沒有重新呈現。 原來是因為這些調用沒有返回刪除或添加對象的新對象列表。 為了解決這個問題,我將其放入我的代碼中

刪除:

  case "DELETE_TRIP_REPORTS_FULFILLED": {
    return {
      ...state,
      userTripReports: state.userTripReports.filter(tripReport => tripReport !== action.response), // Filters the deleted trip report out of userTripReports
    }
  }

帖子:

  case "POST_TRIP_REPORTS_FULFILLED": {
    return {
      ...state,
      userTripReports: state.userTripReports.reverse().concat(action.response).reverse() // The new trip report must be concatted into the first position
    }
  }

這是否違反任何狀態可變性原則?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM