无法使用反应挂钩设置setState

时间:2019-11-19 18:19:38

标签: reactjs typescript react-hooks

此代码将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"
                            >

1 个答案:

答案 0 :(得分:0)

尝试删除您的as CommentPopUp。你为什么需要那个?

相关问题