【发布时间】:2020-08-28 07:24:40
【问题描述】:
我似乎无法访问在 redux-observable 管道中使用 RTK 切片创建的操作的有效负载。我想知道 redux-observable 是否被设计为与 RTK 一起工作,以及我是否应该改用 typesafe-actions。
export const signUrlsEpic = (action$: Observable<Action>): Observable<Action> =>
action$.pipe(
ofType(actions.getPresignedUrls),
exhaustMap((action.payload) => // <- Here: Property 'payload' does not exist on type 'Action<any>'
from(api.getPresignedUrls(action.arguments)).pipe(
map((response) => {
console.log(response)
return actions.setPresignedUrls(response)
})
)
)
)
动作是从 slice.actions 中导出的。我尝试将动作转换为 ActionCreatorWithPayload 但没有帮助。
【问题讨论】:
-
不确定您提供的代码的语法是否正确。尝试使用
exhaustMap(({payload}) => -
除了 action.payload 行之外,VSCode 中没有语法错误。我通过将其更改为 {payload} 得到类似的错误:属性 'payload' 在类型 'Action
' 上不存在
标签: reactjs typescript redux redux-observable redux-toolkit