英文:
Type annotations can only be used in TypeScript files.ts(8010)
问题
I'm getting error on React.MouseEvent<HTMLElement>
const handleOpenNavMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorElNav(event.currentTarget);
};
const handleOpenUserMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorElUser(event.currentTarget);
};
英文:
I'm getting error on React.MouseEvent<HTMLElement>
const handleOpenNavMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorElNav(event.currentTarget);
};
const handleOpenUserMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorElUser(event.currentTarget);
};
答案1
得分: 0
如果是 *.jsx 文件,只需删除:React.MouseEvent
英文:
If it's a *.jsx file, just remove : React.MouseEvent<HTMLElement>. It's a type for typescript.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论