简体   繁体   English

创建我的 React 项目后。当我在 src 中创建组件和上下文文件夹时,我收到此错误。我该怎么办?

[英]After Creating my React Project.When I made Components and Context folder in src I am getting this error.What should I do?

CreateContext.text cannot be compiled under '--isolated modules because it is considered a global script file. CreateContext.text 不能在 '--isolated 模块下编译,因为它被视为全局脚本文件。 Add an import, export, or an empty 'export {}' statement to make it a module.添加导入、导出或空的“导出{}”语句以使其成为模块。

The file CreateContext.text is considered a global script file, which means it is not a module.文件CreateContext.text被认为是一个全局脚本文件,这意味着它不是一个模块。 Are you exporting or importing something in this file?您是否在此文件中导出或导入某些内容? Otherwise, it will keep considering this file as a script and not a module.否则,它将继续将此文件视为脚本而不是模块。

You can check the documentation for isolated modules here.您可以在此处查看隔离模块的文档。

On a side note, you probably shouldn't use .text extension for the context file.附带说明一下,您可能不应该为上下文文件使用.text扩展名。 You can keep using .js or .jsx .您可以继续使用.js.jsx

暂无
暂无

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

相关问题 我在使用 React 制作的项目中遇到未定义的错误 - I'm getting an undefined error in my project made with React 为什么我在系统中第一次运行 react js 项目时收到此错误消息? - Why I am getting this error message when I run react js project first time in my system? 当我尝试运行我的 React 项目时出现错误 - I am getting an error when I try to run my react project 创建新的 React 应用程序时出现错误 - I am getting an error when creating a new react app 你如何访问多个组件中的反应挂钩? 我的反应钩子做错了什么? - How do you access react hooks in multiple components? What am I doing wrong with my react hook? 尝试注册一个编译 srcipt 但 src 不存在,而我实际上在我的公共文件夹中有它,我该怎么办? 反应 - Trying to register a compile srcipt but src does not exist and I actually have it on my public folder, what do I do?? REACT 在创建React组件时,我应该使用功能组件,React.createClass还是扩展React.Component? - When creating React components should I use functional components, React.createClass or extends React.Component? 为什么我在控制台中未定义,当我尝试使用 typescript 订阅和使用我的上下文并做出反应时 - Why am i getting undefined in my console, when i try to subscribe and use my context using typescript and react 创建高阶组件时应如何“思考”? - How should I “think” when I am creating higher order components? 列表中的每个孩子都应该有一个唯一的“关键”道具,我在我的反应原生应用程序中遇到了这个错误 - Each child in a list should have a unique "key" prop, I am getting this error in my react native app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM