【发布时间】:2021-06-08 18:59:14
【问题描述】:
我有一个汇编表单步骤的打字稿代码,它在构建时给我一个错误,这是函数,它给我一个错误就行了:
setVisitedForms((seenForms) => [...seenForms, currentIndex].sort((x, y) => x - y));
const push = useCallback(
(form = nextForm) => {
if(!!currentForm) {
const currentIndex = forms.indexOf(currentForm);
if (currentIndex >= 0) {
setVisitedForms((seenForms) => [...seenForms, currentIndex].sort((x, y) => x - y));
}
history.push(`${baseurl}${form}`);
}
},
[baseurl, history, nextForm, currentForm, forms, setVisitedForms]
);
这是控制台上出现的错误。有谁知道我做错了什么?
Argument of type '(seenForms: never[]) => number[]' is not assignable to parameter of type 'SetStateAction<never[]>'.
【问题讨论】:
标签: javascript typescript