【问题标题】:What does the <{}> mean in react class?<{}> 在反应类中是什么意思?
【发布时间】:2018-06-17 18:28:04
【问题描述】:

好久没接触RN了,还是停留在ES6语法上。

然后我看到export default class App extends Component&lt;{}&gt; { 并开始想知道 是什么意思,有人可以帮忙吗?

【问题讨论】:

    标签: typescript react-native ecmascript-6


    【解决方案1】:

    这可能与类型(TypeScript)有关,{} 表示用于道具的类型。看看这个答案 - TypeScript any vs Object

    查看React typesinterface Component&lt;P = {}, S = {}&gt; extends ComponentLifecycle&lt;P, S&gt; { }的源代码类型P是props的类型,S是与组件状态相关的类型。

    【讨论】:

      【解决方案2】:

      流程
      它与道具的流类型相关 - https://flow.org/en/docs/react/components/

      &lt;{}&gt;是一个空对象的定义,表示该组件没有额外的属性。

      参考
      React-Native Feature Request

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-08-12
        • 2017-06-11
        • 2018-03-05
        • 2023-03-27
        • 2016-08-17
        • 2010-12-28
        • 2011-06-10
        相关资源
        最近更新 更多