Jam*_* Ko 7 javascript commonjs ecmascript-6 flowtype react-native
index.js在我的 React Native 项目中,我有很多这样的代码分散在文件中:
import Restaurant from './Restaurant';
import Store from './Store';
import Vineyard from './Vineyard';
import Wine from './Wine';
export {
Restaurant,
Store,
Vineyard,
Wine
};
Run Code Online (Sandbox Code Playgroud)
写起来非常重复和乏味。有没有办法可以自动重新导出当前工作目录中的所有其他文件index.js?(请注意,我还在项目中使用Flow ,因此任何解决方案都应保留它可以推断的类型信息。)
谢谢。
Isa*_*aac 13
export * from './Restaurant';
export * from './Store';
Run Code Online (Sandbox Code Playgroud)
通过使用上述语法,您可以访问每个组件的所有导出属性并直接导出它们。
Actions当您将所有内容分组到每个单独的Action文件中index.js并直接导出它们时,这是一种常见的模式。你可以看看 github repo
| 归档时间: |
|
| 查看次数: |
6213 次 |
| 最近记录: |