What is the purpose of having functions like componentWillMount in React.js?

前端 未结 5 859
一个人的身影
一个人的身影 2021-02-04 00:32

I have been writing components in React.js recently. I have never had to use methods like componentWillMount and componentDidMount.

rend

5条回答
  •  隐瞒了意图╮
    2021-02-04 01:18

    In my project which is a dashboarding tool, I have used componentDidMount().

    On home page previously saved dashboards appear on the sidebar. I make an ajax call within componentDidMount() of component rendering Homepage, so as to fetch list of dashboards asynchronously after the page has been rendered.

提交回复
热议问题