【问题标题】:React/Zustand - Module parse failed: Unexpected token. You may need an appropriate loader to handle this file typeReact/Zusand - 模块解析失败:意外的令牌。您可能需要适当的加载程序来处理此文件类型
【发布时间】:2022-08-09 06:13:35
【问题描述】:

我在我的 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>

    标签: javascript reactjs zustand


    【解决方案1】:

    在调试了很长时间并尝试了很多次之后,我后来得到了问题所在,但不明白为什么这本身就是引发问题的原因。

    我只需将{course?.title} 更改为{course.title},代码就可以成功编译而没有问题。因此,删除? 使其工作。

    我希望这可以帮助那里的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-12
      • 2019-02-26
      • 2021-12-04
      • 2022-11-10
      • 2018-02-27
      • 2019-01-28
      • 2021-02-10
      • 1970-01-01
      相关资源
      最近更新 更多