4 ms·
I have found better success personally with "presentational vs container" instead of "view vs controller" as you describe it. For example, a checkbox IMHO woul
by franciscop 6y ago
I have found better success personally with "presentational vs container" instead of "view vs controller" as you describe it.
For example, a checkbox IMHO would be better considered a presentational component even if it manages the small bit of state it needs for it to work. Same with many of the state management that is around "visual" changes.
The point where I normally decide to split it up like you say into sub-components is just when the component becomes too complex.
- elanning 6y agoYes, many have found good success with putting a minor bit of UI state into the "mostly pure" view components. It works well until some other part of the app needs to uncheck the checkbox due to some new business requirement. This is why I usually provide a nice default "useCheckbox" hook in the same file as the pure Checkbox component.