【问题标题】:React component props wrapped inside braces?包裹在大括号内的反应组件道具?
【发布时间】:2020-06-05 05:35:09
【问题描述】:

我有一个组件定义为:

type myType = anotherType<weirdType1, weirdType2, weirdType3>;

function weirdComponent({q}: myType)

它被称为:&lt;weirdComponent {...myVar} /&gt;,其中myVarmyType 的一个实例。

  • {q} 在奇怪组件函数签名中是什么意思

  • {...myVar} 有什么作用?

  • myType 是什么类型?

【问题讨论】:

标签: javascript reactjs typescript


【解决方案1】:

奇怪组件函数签名中的 {q} 是什么意思

它的参数destructuring

{...myVar} 有什么作用?

它的spreading attributes

myType 是什么类型?

它的anotherType&lt;weirdType1, weirdType2, weirdType3&gt;;。您可以将鼠标悬停在其上以查看详细信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-21
    • 2019-05-31
    相关资源
    最近更新 更多