React re-write componentWillReceiveProps in useEffect

后端 未结 4 1455
情话喂你
情话喂你 2020-12-18 13:47

So I am re-writing a component with hooks, and I ran into an interesting challenge, I need to mimick some old behaviour of componentWillReceiveProps with the

4条回答
  •  再見小時候
    2020-12-18 14:35

    You don’t need hooks to handle prerender lifecycle. Just put the things in the functional component before returning JSX as the function itself is equivalent to render method of class based component.

提交回复
热议问题