代码
import { takeLatest, put, select } from 'redux-saga/effects'
import { GET_COMMENT_LIST } from './actionTypes'
import { fetch } from '../../../common/index'
import { initCommentList } from './actionCreators'
interface IAction {
commentType?: string,
page?: number | string
}
function* axiosCommentList({ commentType, page }: IAction) {
const user = yield select((state: { user: { user: string } }) => state.user.user)
try {
const formData = {
type: commentType,
page: page,
pageSize: 10,
create_user: user,
to_user: user
}
const {
data: {
data: { result, total }
}
} = yield fetch.post('/api/comment/getusercommentlist', formData)
yield put(initCommentList(result, total))
} catch (e) {
console.log(e.message)
}
}
export function* getCommentList() {
yield takeLatest(GET_COMMENT_LIST, axiosCommentList)
}
takeLatest 会报错
No overload matches this call.
The last overload gave the following error.
类型“string”的参数不能赋给类型“TakeableChannel<unknown>”的参数。
但是我把 IAction 改下就不会报错了
interface IAction {
commentType?: string,
page?: number | string,
[x: string]: any
}
=.=有没有大佬遇到过
解决了
IState 继承下官方 Action 即可