React Redux Project template by Visual Studio 2019, JavaScri



有人可以解释一段来自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 参数。该函数返回键入为 AppThunkAction 的新函数或 thunk 操作 https://github.com/reduxjs/redux-thunk。AppThunkAction是一个内部接口,你可以在"store/index.js"中找到它。 KnownAction 是可能参数的接口,它作为 AppThunkAction 类型的参数传递。

希望对您有所帮助。

它指的是动作创作者。看看 redux-thunk 中间件

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

最新更新