如何在ReactTS中导出带有子级的组件?

问题描述

我导入了这个组件

import { someComponent } from './someComponent';

然后我声明一个新组件,它将是被调用组件的子组件

const anotherComponent = () => {...};

我以这种方式导出

export { someComponent(anotherComponent) };

但是我收到以下(不是很有帮助)错误Parsing error: ',' expected.

解决方法

看来做这件事的好方法是

export const newVariable = someComponent(anotherComponent);

我认为最好的选择是将文件命名为导出变量;)