[英]Why does my editor say "'await' has no effect on the type of this expression"?
為什么我的編輯器 (PHPStorm) 說我不需要“等待”? 它工作正常... 這是代碼: ...
[英]Why does my editor say "'await' has no effect on the type of this expression"?
為什么我的編輯器 (PHPStorm) 說我不需要“等待”? 它工作正常... 這是代碼: ...
[英]difficulty using store & reducer UnCaught Error: Actions must be plain objects
暈家伙,我正在創建一個項目使用 redux 反應 & 我得到這個錯誤,我不熟悉下面是我的代碼 & 錯誤店鋪 切片文件 #其他頁面 錯誤消息 請任何人幫助或知道我如何解決這個錯誤 ...
[英]How we can combine the selector in Redux?
假設我想要來自 3 個不同減速器的 3 個數據。 一般來說,我可以做這樣的事情! 那么如何使用單個useSelector獲得相同的結果 ...
[英]why does my createAsyncThunk function fetch data multiple times instead of once
我正在嘗試使用 React 和 Redux 制作一個簡單的博客網頁(按照教程進行)。 我創建了一個 redux 商店,制作了一個帖子切片,用於管理與帖子有關的所有內容,我在使用 redux thunk 獲取數據時遇到了一些問題。 當我運行博客頁面時,我會看到每篇文章中的兩篇。 不確定問題是來自我用來 ...
[英]"No overload matches this call." while calling an AsyncThunk function (redux toolkit)
我對以下createAsyncThunk方法有疑問: 這里沒有問題,但是當我嘗試從登錄頁面dispatch這個 function 時, 我收到此錯誤: 沒有過載匹配此調用。 重載 1 of 3, '(thunkAction: ThunkAction<Promise<PayloadAct ...
[英]Queue and pause Redux actions while offline
我想在我離線時暫停所有派遣的 thunk,並在我重新在線時恢復。 createListenerMiddleware 是一個不錯的選擇嗎? 我可以創建一個單獨的 redux 切片來保存已分派的操作並重新分派它們,但這將導致現有的 thunk 返回一個被拒絕的 Promise 並在調用的地方拋出錯誤。 ...
[英]Thunk Middleware: how/why does action creator have access to dispatch when it's not passed in?
作為參考,這是以下屏幕截圖的來源: https://github.com/gopinav/React-Redux-Tutorials/blob/master/redux-demo/asyncActions.js 查看下面屏幕截圖中的fetchUsers操作創建者 function, dispatc ...
[英]How to work with middlewares in redux toolkit?
我在 redux 工具包中使用切片。 在 slice 的一個動作中,我有從其他動作復制的代碼,因為在動作中你不能調用另一個動作。 我想把checkWinner這個action的邏輯全部放到中間件里面,但是在configureStore. 在checkWinner我需要實際的 state。 而且,我 ...
[英]How can I await for an async action dispatch on the click of a button?
我有這個反應組件,用戶想要發送登錄請求,但每當我分派操作時,甚至在它執行之前,我的組件中的進一步代碼就會被執行。 我試過將登錄請求 function 設為async ,甚至嘗試在分派操作之前使用 await,但這一切都是徒勞的。 組件文件: 授權操作: 授權減速器文件: 我的商店文件: 根減速器: ...
[英]redux toolkit dipatching buildercase twice actions
我想弄清楚為什么在刷新期間調度操作會運行兩次並且端點也被調用兩次。 這是我的切片 在我的組件中,我是這樣設置的 關於為什么在 .network 選項卡中調度被調用兩次並且端點被調用兩次的任何想法? ...
[英]Can't update my state for no apparent reason with Redux Toolkit
我是 Redux 工具包的新手,我想我錯過了一些東西,即使看起來我做的一切都是對的。 這是我的測試用例: 因此,以下 SUT(被測系統): console.log(action.payload)打印出我所期望的,即 10 個骰子的數組。 我嘗試推送、連接、返回 state,而不是返回它(因為 I ...
[英]How to export actions generated from extraReducers and createAsyncThunk
我正在嘗試使用 Redux 工具包中提供的 function 編寫我的第一個異步 thunk: createAsyncThunk 。 但是在閱讀文檔和在線說明數小時后,我似乎遺漏了一些東西,因為我無法導入動作rollDice 。 GenerateRandomDice.spec.ts diceSlic ...
[英]"add to cart" feature using react redux-toolkit and localstorage not working
我正在使用 redux-toolkit 向電子商務網站添加“添加到購物車”功能。 我也在使用本地存儲和 thunk 中間件,但它不工作。 控制台上沒有任何顯示。 這段代碼有什么問題? Redux 開發工具這是 CartSlice.js 代碼 這是 Store.js 代碼 這是 CartScreen ...
[英]How to handle rejected message with redux/toolkit in a right way
我有一個關於處理拒絕值的問題。 如果我嘗試使用存在的 email 和密碼分配 function,一切正常,但是當我輸入隨機的 email 和密碼時,我無法到達來自后端的 404 錯誤消息。 這是我的切片代碼 這是服務代碼 這些是來自后端的值。 如果我輸入隨機 email 和密碼,后端返回{ "cod ...
[英]How can I skip first argument to the payload creator of Redux Thunk using typescript
此片段來自 redux-tooklit 文檔。 這里我要用get請求,所以不會傳arguments。 如何跳過payload creator userId的第一個參數 ...
[英]Redux and NextJS 13
我正在嘗試使用第 13 版 next 和 redux 構建 NextJs 應用程序。我找到了在應用程序中傳遞 redux 提供程序的方法,但我仍然不明白接下來的事情:How can I use "createAsyncThunk" actions or RTK query with "getSta ...
[英]Extra reducer not catching error from Axios async request with redux Thunk
我正在向服務器發出一個簡單的請求並且它有效。 我操縱到 url 以確保錯誤也得到正確管理,但它不起作用。 盡管我創建的 thunk 確實捕獲了錯誤,但被拒絕的案例永遠不會在額外的 reducer 中觸發。 我不確定可能是什么問題。 看下面這個減速器: 我使用數據的組件如下: ...
[英]TypeError: Cannot destructure property 'rejectWithValue' of 'thunkAPI' as it is undefined
我正在關注此代碼的教程: 我閱讀了文檔,但顯然這段代碼應該沒有任何問題。 盡管如此,我還是收到rejectWithValue未定義的錯誤。 那么問題是什么? 我有安裝一些 package 嗎? 還是符號改變了? ...
[英]extraReducers not working when I'm trying to watch for the action on my slice on the same file
每次發送 fillForm 操作時,我都試圖觸發額外的減速器。 但代碼不工作。 有什么幫助嗎? 我嘗試了幾種方法,但沒有任何幫助 ...
[英]What redux-thunk offer for async call?
我剛剛熟悉redux和redux-thunk 。 我嘗試使用下面的代碼片段來處理async調用,使用redux和redux-thunk 。 CodeSandBox 上的代碼這絕對可以正常工作並給出預期的 output。 還嘗試了沒有thunk和一些更改的相同示例, CodeSandBox 上的 ...