我在我的类型脚本中添加了一个弹出窗口,我只是不能解决这个问题
Type '(close: any) => Element' is not assignable to type 'ReactNode'.
<Popup
trigger={
<button
className="fixed bottom-10 right-10 h-20 w-20 justify-center flex items-center bg-blue-200 rounded-lg hover:bg-blue-500"
onClick={() => handleResult()}
>
<Submit />
</button>
}
closeOnDocumentClick={false}
modal
>
{(close) => (
<div className="fixed right-1/2 top-1/2 h-32 border-2 w-64 bg-slate-300 border-slate-400 flex items-center justify-center rounded-xl">
<button
className="absolute right-1 top-1 rounded-xl border-2 h-7 w-10 bg-red-500 "
onClick={() => close()}
>
<p> x</p>
</button>
<Link
to="/result"
state={{ diagnosisResult: result, remark: remark }}
className={textStyle}
>
View Result Here!!!
</Link>
</div>
)}
</Popup>
我试过做(close : ()=>void)
,但它仍然不工作,所有尝试不同的解决方案,我可以找到,但都不工作(我的意思是代码是正确的工作,只是错误仍然弹出),所以我不能在vercel上运行它
1条答案
按热度按时间nx7onnlm1#
在里面,你只是delcaring你箭头函数((关闭:any)=> Element)而不调用它。我只是把你的函数用括号括起来,然后叫你function:
您编辑的代码