簡體   English   中英

如何為每個用戶事務保存 redux state

[英]How to save redux state per user transaction

I have a redux react web app booking court app and I want to manage/store redux state based on the user unique id that is coming from the server when the user initials the booking. 目前我最初的 state 看起來像這樣:

 const initialState = {
        payload: [],
        loading: false,
}

我有一個減速器

const courtReducer = (state =initialState, action: any) => {
      switch(action.type) {
      case MAKE_BOOKING:
        return {
         ...state,
         loading,
         payload: action.data
        };
       other action...
      }
}

我不確定我是否有道理。

如果您想弄清楚如何存儲state,也許 Redux 文檔的“使用 Thunks 發送數據”部分會有所幫助。 它是教程的一部分,應該讓您很好地了解如何將異步 API 調用與減速器集成。

暫無
暫無

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

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