Heim  >  Fragen und Antworten  >  Hauptteil

javascript - react使用变量声明方式如何设置this.state以及componentDidMount生命周期函数

我知道通过Class创建的组件可以在super后设置this.state,以及使用componentDidMount函数,但是对于这种变量声明类的又该怎么去使用react的this.state和生命周期函数呢

黄舟黄舟2723 Tage vor285

Antworte allen(2)Ich werde antworten

  • 阿神

    阿神2017-04-11 11:57:57

    你这本身就是无状态函数组件, 要使用生命周期就别写这种组件

    Antwort
    0
  • ringa_lee

    ringa_lee2017-04-11 11:57:57

    请参考functional类型组件class类型组件的不同之处,以及各自的特点。。。

    Antwort
    0
  • StornierenAntwort