在create-react-app中使用来自"./Name"的导出名称? [英] Using export Name from "./Name in create-react-app?

查看:47
本文介绍了在create-react-app中使用来自"./Name"的导出名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将React应用程序移入Create-React-App,但努力使某些事情正常工作,并且实际上不知道Create-React-允许和禁止的内容(关于自定义和添加额外的模块)应用程序.

I am trying to move a React app into Create-React-App but struggling to get some things to work and not really knowing what is and what isn't allowed (regarding customisation and adding extra modules) with Create-React-App.

当前带有React应用程序源的CRA无法在以下位置进行编译:

Currently the CRA with the source from the React app is failing to compile at:

export App from "./App/App"

有错误:

./src/containers/index.js
SyntaxError: /Volumes/Mexico/Workspace/create-react-app-test/myapp/src/containers/index.js: Support for the experimental syntax 'exportDefaultFrom' isn't currently enabled (1:8):

Add @babel/plugin-proposal-export-default-from (https://git.io/vb4yH) to the 'plugins' section of your Babel config to enable transformation.

我不希望从CRA中退出,也不相信我可以更改Babel的配置,所以我不确定该怎么做.

I don't wish to eject from CRA and I don't believe I can change the Babel configuration so I am not sure what to do.

CRA支持此语法吗?如果是这样,我应该怎么做才能使其正常工作.如果没有,我是否必须重写所有代码?

Is this syntax supported in CRA? If so, what should I do to get it to work. If not, do I have to rewrite all the code?

反应脚本2.1.8节点v11.14.0npm 6.9.0

react-scripts 2.1.8 node v11.14.0 npm 6.9.0

谢谢,阿什利.

推荐答案

从"./App/App"导出应用程序不在受支持的

export App from "./App/App" is not among supported export syntax variations.

为了符合规范,可以将其更改为:

In order to be spec-compliant, it can be changed to:

export { default as App } from "./App/App"

这篇关于在create-react-app中使用来自"./Name"的导出名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆