无法访问使用Redux Toolkit创建的ActionCreator的action.payload

问题描述 投票:0回答:1

我似乎无法访问在Redux可观察的管道中使用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,但没有帮助。

reactjs typescript redux redux-observable redux-toolkit
1个回答
0
投票

实际上错误很明显!有效负载不可用的原因是因为我将类型声明为Observable<Action>。应该已经声明为Observable<PayloadAction>

© www.soinside.com 2019 - 2024. All rights reserved.