vroqjs.com

08-recipes/04-add-a-section.md

Add a section

Add a section

Use this recipe when a feature UI is becoming too large or when one visible part of a feature deserves a clear name and boundary.

A section is the right choice when the UI fragment is feature-local and often store-aware.

Steps

1. Identify a clear UI responsibility inside the feature. 2. Extract that responsibility into a section file. 3. Keep the section focused on one visible part of the feature. 4. Let the section read the state and dispatch the actions it needs. 5. Keep raw transport logic out of the section.

Where it should live

A section should usually live inside the owning feature:

features/featureName/sections/

or directly inside the feature folder if the feature is still small.

What to avoid

Do not create a section when:

  • the code is really a reusable presentation component
  • the UI fragment is too small to justify a new file
  • the section is becoming a second full feature

Final rule

Create a section when it makes a feature easier to read without breaking feature ownership.