【问题标题】:How can I export a component with children in ReactTS?如何在 ReactTS 中导出带有子组件的组件?
【发布时间】:2020-08-26 11:49:26
【问题描述】:

我导入这个组件

import { someComponent } from './someComponent';

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

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

我是这样导出的

export { someComponent(anotherComponent) };

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

【问题讨论】:

  • export const combined = <someComponent><anotherComponent></someComponent></anotherComponent>;

标签: typescript export react-tsx


【解决方案1】:

看来这样做的好方法是

export const newVariable = someComponent(anotherComponent);

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

【讨论】:

    猜你喜欢
    • 2013-08-01
    • 2023-01-05
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-02
    相关资源
    最近更新 更多