UseEffect, usecallback, and useMemo all have a second parameter. If the dependency represented by the second parameter changes, it will be re-rendered. If it is not executed, no update will be rendered

useEffect

UseEffect takes two arguments. The first argument is a callback function and the second argument is an array that accepts the state of the current function. The callback function is executed if the state of the second argument changes.

UseEffect only applies to status updates in the current function;

usecallback

The parent component passes a method to the child component. If other states of the parent component change, the child component will also render multiple times, resulting in a performance waste. Usecallback is a method that is cached from the parent component to the child component, and the child component is rerendered only when the state of the second parameter in usecallback changes.

useMemo

The parent component passes a value to the child component. If other values of the parent component change, the child component will also render multiple times, resulting in a performance waste. UseMemo caches the value passed from the parent component to the child component, and the child component is re-rendered only when the state of the second parameter in the useMemo changes.

Reference: blog.csdn.net/weixin_4390…