Redux的mimi

1.useContext

image.png

声明createContext
复制代码

image.png

使用useContext
复制代码

image.png

2.renducer规范state创建流程

image.png

3.dispatch规setState流程

所有使用到userModefier的地方用外部组件Wrapper包裹,这样读写的数据直接到Wrapper中了,userModefier里操作数据
复制代码

image.png

4.connect高阶组件

避免了用写死的外部组件Wrapper包裹userModifier,在用的时候使用connect函数即可实现数据和操作分离的效果
复制代码

image.png

5.有效减少render

image.png

当我们操作数据时所有组件全都进行了render
复制代码

方式一 使用useMemo或useCallback

image.png

修改setState

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享