useState本质上是简易版的useReducer
在mount阶段,两者的区别为:
- useState的lastRender就是basicStateReducer
- useReducer的lastRender就传入的reducer
所以useState可以视为reducer参数是basicStateReducer的useReducer
在update阶段:
updateState内部调用的就是updateReducer,传入的reducer仍然是basicStateReducer
useState本质上是简易版的useReducer
在mount阶段,两者的区别为:
所以useState可以视为reducer参数是basicStateReducer的useReducer
在update阶段:
updateState内部调用的就是updateReducer,传入的reducer仍然是basicStateReducer