You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionParent({ a, b }){// Only re-rendered if `a` changes:constchild1=useMemo(()=><Child1a={a}/>,[a]);// Only re-rendered if `b` changes:constchild2=useMemo(()=><Child2b={b}/>,[b]);return(<>{child1}{child2}</>)}
通过useMemo 对组件进行性能优化
注意这种方式在循环中是无效的,因为 Hook 调用 不能 被放在循环中。但你可以为列表项抽取一个单独的组件,并在其中调用 useMemo。
The text was updated successfully, but these errors were encountered: