useState和useReducer区别
useState本质上是简易版的useReducer
在mount阶段,两者的区别为:
- useState的lastRender就是basicStateReducer
- useReducer的lastRender就传入的reducer
所以useState可以视为reducer参数是basicStateReducer的useReducer
在update阶段:
updateState内部调用的就是updateReducer,传入的reducer仍然是basicStateReducer
原文地址:https://blog.csdn.net/qq_42931285/article/details/136142504
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!