Design Patterns · Middle · Question 29 of 75
Where should business rules (e.g. discount calculation) live in a frontend app?
- ✓Correct answer: In pure functions of a domain layer used by components and hooks
- 2Right in the component's JSX, so the logic sits next to the rendering
- 3In CSS via variables, so as not to burden JavaScript
Explanation
Rules scattered across components get duplicated and are hard to test. Pure functions in entities/domain are reused across screens, on the server and in tests without rendering.