Skip to main content

Comparison With hooks

비즈니스 로직과 화면 렌더코드의 분리

x-view-model is mainly used to separate UI and business logic, which can solve some of the problems caused by the official react hooks.

hooks component issuesx-view-model
Usually need to set multiple useStates, can't update property values at fine granularitySupport update and deconstruct data by object form, support update property values at fine granularity
When the component reaches a certain complexity, the code piled up together will become more and more difficult to maintainUI and logic are well separated, code is well organized
The closure trap problem of React HookSince the methods are maintained in the class, there is no such problem
there is thinking burden while using useReducer+context to global shared statean intuitive api and simple to use
useState updater can't implement immutable data, even memo wrapped subcomponents will be re-renderedcan implement immutable data by state keys, won't re-render subcomponents