![](/img/trans.png)
[英]React - Module parse failed: Unexpected Token. You may need an appropriate loader to handle this file type
[英]React/Zustand - Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type
我在我的 react 应用程序中遇到错误,不确定错误本身来自何处,并且代码似乎干净且没有错误,并且遵循最佳实践。
Error Log
Failed to compile.
./src/components/CourseList.jsx 74:14
Module parse failed: Unexpected token (74:14)
You may need an appropriate loader to handle this file type.
| columnNumber: 17
| }
> }, course?.title), /*#__PURE__*/React.createElement("button", {
| className: "delete-btn",
| onClick: function onClick() {
courseList.jsx
<span className="course-title">{course?.title}</span>
<button
className="delete-btn"
onClick={() => {
removeCourse(course.id);
}}
>
Delete Course
</button>
在调试了很长时间并尝试了很多次之后,我后来得到了问题所在,但不明白为什么这本身就是引发问题的原因。
我只需将{course?.title}
更改为{course.title}
代码就可以成功编译而没有问题。 因此,删除?
让它工作。
我希望这可以帮助那里的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.