vroqjs.com

08-recipes/03-add-a-feature.md

Add a feature

Add a feature

Use this recipe when a new slice of application behavior deserves its own ownership boundary.

A feature is the right choice when the behavior includes UI, state, actions, or API logic that belong together.

Steps

1. Check whether the behavior belongs inside an existing feature. 2. Create a new feature only if the behavior is a distinct app capability. 3. Add a feature folder under features/. 4. Add only the files that have a clear responsibility. 5. Register the reducer in configureStore.js if the feature owns state. 6. Keep feature logic inside the feature folder.

Typical feature structure

features/featureName/
  index.js
  featureActions.js
  featureReducer.js
  FeatureSection.js
  apiClient.js

Only create the files that are actually needed.

What to avoid

Do not create a new feature when:

  • the behavior is only a reusable UI unit
  • the behavior belongs inside an existing feature
  • a new section or component is enough

Final rule

Create a feature when the behavior needs its own clear boundary for state, UI, and debugging.