Skip to content

Instantly share code, notes, and snippets.

@mxstbr

mxstbr/readme.md Secret

Created September 8, 2016 17:08
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxstbr/eb293604205b5154345712ce71d0f398 to your computer and use it in GitHub Desktop.
Save mxstbr/eb293604205b5154345712ce71d0f398 to your computer and use it in GitHub Desktop.
Why Feature based architecture makes sense

Let's assume a NavBar component that has a toggleNav action. In a standardly structured redux app with actions/, reducers/ and components/ folders, this is what this would look like when I want to toggle the nav from the `HomePage``:

// HomePage.js

import { toggleNav } from '../actions';

Now let's go with a feature based architecture. This is what the import looks like when we have a Navbar folder that has all the things related to it inside:

// HomePage.js

import { toggleNav } from '../NavBar/actions';

In my opinion, that second one makes so much more sense than the first one! Actions are still global, but they are related to a component.

Note: One can still have truly global actions in the top-level <App /> wrapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment