Does a render happen before function in React Hooks useEffect is called?

后端 未结 2 1258
误落风尘
误落风尘 2020-12-03 13:53

I would have thought that useEffect\'s first function gets called before the first render, but when I call the method below, my console.log just before the return method cal

2条回答
  •  天命终不由人
    2020-12-03 14:29

    According to the useEffect documentation:

    If you’re familiar with React class lifecycle methods, you can think of useEffect Hook as componentDidMount, componentDidUpdate, and componentWillUnmount combined.

    So yes, it runs after the first render and each subsequent render.

提交回复
热议问题