此代码将setState用于对象对我不起作用。
const [showCommentPopup, setShowCommentPopup] = useState({ showPopUp: false, commentText: '',type: ''} as CommentPopUp);
<Button
aria-label="addComment"
onClick={() => setShowCommentPopup({showPopUp: true, type: expenseType, commentText: comments || ''})
}
data-testid="add-comment"
>
答案 0 :(得分:0)
尝试删除您的as CommentPopUp
。你为什么需要那个?