简体   繁体   English

React/Zusand - 模块解析失败:意外的令牌。 您可能需要适当的加载程序来处理此文件类型

[英]React/Zustand - Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type

I am facing an error in my react app, not sure where the error itself is coming from and the code seems to be clean and bug-free and also following best practices.我在我的 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>

After a really long time debugging what the issue was and so many tries, I later got what the issue was but don't understand why that itself was what was throwing the issue.在调试了很长时间并尝试了很多次之后,我后来得到了问题所在,但不明白为什么这本身就是引发问题的原因。

I simply had to change this, {course?.title} to this {course.title} and the code got compiled successfully without issues.我只需将{course?.title}更改为{course.title}代码就可以成功编译而没有问题。 Thereby, removing the ?因此,删除? to make it work.让它工作。

I hope this helps someone out there.我希望这可以帮助那里的人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React - 模块解析失败:意外的令牌。 您可能需要适当的加载程序来处理此文件类型 - React - Module parse failed: Unexpected Token. You may need an appropriate loader to handle this file type 模块解析失败:意外的令牌(7:5)您可能需要适当的加载程序来处理此文件类型。 :Webpack,Bootstrap - Module parse failed: Unexpected token (7:5) You may need an appropriate loader to handle this file type. : Webpack, Bootstrap 模块解析失败:意外令牌 (41:41) 您可能需要适当的加载程序来处理此文件类型 - Module parse failed: Unexpected token (41:41) You may need an appropriate loader to handle this file type 模块解析失败:意外标记 (1:0) 您可能需要适当的加载程序来处理此文件类型。 - Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type. <!DOCTYPE html> Web3-react 错误模块解析失败:意外令牌您可能需要一个适当的加载程序来处理此文件类型。 web3-反应/钱包连接 - Web3-react Error Module parse failed: Unexpected token You may need an appropriate loader to handle this file type. web3-react/walletconnect Webpack 4:模块解析失败:意外字符“@”。 你可能需要一个合适的加载器来处理这种文件类型…… - Webpack 4: Module parse failed: Unexpected character '@'. You may need an appropriate loader to handle this file type… React-如何解决模块解析失败错误:您可能需要适当的加载器来处理此文件类型 - React - How to solve Module Parse Failed Error: You may need an appropriate loader to handle this file type Webpack + React:模块解析失败:意外的令牌:您可能需要一个合适的加载器 - Webpack + React: Module parse failed: Unexpected token: You may need an appropriate loader 模块解析失败:您可能需要一个合适的加载器来处理此文件类型,目前没有配置加载器来处理此文件 - Module parse failed: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file Webpack 无法加载 pdf 文件:模块解析失败 您可能需要适当的加载程序来处理此文件类型 - Webpack Cannot load pdf file: Module parse failed You may need an appropriate loader to handle this file type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM