复合组件通信:上下文方案

40 阅读1分钟

类组件

  • 子组件
    • 优化 :pure component

image.png

image.png

-父组件

image.png

函数组件

只跟传的两个值(supNum,oppNUm)有关系就去掉了 useCallback memo 只会比较属性更新,不会比较上下文更新

  • 子组件

image.png

image.png

  • 父组件

image.png