javascript - create-react-app (TypeScript) .babelrc throwIfNamespace=true 设置
问题描述
以为这很简单,但事实并非如此。我使用最新的 create-react-app 生成了一个简单的应用程序。添加<gcse:search>
标签并获得以下信息:
Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can turn on the 'throwIfNamespace' flag to bypass this warning.
16 | return (
17 | <div className="comptext">
> 18 | <gcse:search defaultToRefinement="mostly-center"></gcse:search>
| ^
19 | </div>
20 | );
.babelrc 是:
{
"presets": [
[
"@babel/preset-react",
{
"throwIfNamespace": false
}
]
]
}
我尝试了多个 .babelrc 配置,package.json 中的“babel”键,甚至尝试包括 .bablerc.js。没变
如果可能的话,我宁愿不弹出这个。
我错过了什么?
解决方案
您需要按如下方式设置:
"throwIfNamespace"`: false in file `@babel/preset-react/index.js
推荐阅读
- javascript - 记忆游戏 - 隐藏 img - jQuery
- node.js - Node 中有多少线程
- javascript - 关闭谷歌广告管理器标签中的 div 脚本
- mongodb - mongodb中是否有类似于日志的读取操作?
- android - 尝试将文件上传到 OData 服务时出现 DataStreamException
- field - FileMaker Pro TextColor 作为表中字段的计算
- reactjs - React Material ui - 居中项目表单
- javascript - 获取会话过期通知 [Node.js / Express 会话]
- teradata - 如何在 teradata 中验证 XML 格式是否正确
- java - ModelMapper - 扁平化对象的简单方法