How to use lifecycle methods with hooks in React?

后端 未结 4 2116
轮回少年
轮回少年 2020-12-13 11:11

I have gone through hooks introduced in react v16.7.0.

https://reactjs.org/docs/hooks-intro.html

So my understanding about hooks is we can play with state i

4条回答
  •  既然无缘
    2020-12-13 11:26

    Functional components are purly stateless components. But in React 16.8, they have added Hooks. Hooks can be used in place of state and lifecycle methods.

    Yes, you can think of useEffect Hook as Like

    • componentDidMount

    • componentDidUpdate,

    • componentWillUnmount

    • shouldComponentUpdate combined.

    • Note It is a close replacement for componentDidMount , componentDidUpdate and , componentWillUnmount & shouldComponentUpdate

提交回复
热议问题