簡體   English   中英

Visual Studio 2019 的 React Redux 項目模板,JavaScript 問題

[英]React Redux Project template by Visual Studio 2019, JavaScript question

有人可以解釋一段來自 React Redux Visual Studio 模板的代碼(JavaScript + TypeScript)嗎? 我要求澄清的課程可在此處獲得:

https://github.com/dotnet/aspnetcore/blob/master/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/ClientApp/src/store/WeatherForecasts.ts

我想要解釋的特定代碼行是: requestWeatherForecasts: (startDateIndex: number): AppThunkAction<KnownAction> => (dispatch, getState)

我知道,這是一個簡單的語法問題,請幫忙:)

所以,首先它完全是 TypeScript :) 它不是 JS 和 TS 的混合代碼。

requestWeatherForecasts 函數是 actionCreators 對象的一個​​字段,它接收輸入為數字的 startDateIndex 參數。 該函數返回一個新函數或一個 thunk 動作https://github.com/reduxjs/redux-thunk ,其類型為 AppThunkAction。 AppThunkAction 是一個內部接口,你可以在“store/index.js”中找到它。 KnowAction 是一個可能參數的接口,它作為 AppThunkAction 類型的參數傳遞。

希望它會幫助你。

它指的是動作創建者。 看看 redux-thunk 中間件

https://github.com/reduxjs/redux-thunk

暫無
暫無

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

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