I’m currently working on a React project using Redux. I was putting all my actions into one file, but it quickly became unmanageable. Weirdly, I’ve had a hard time to find a nice example showing up how to split all your actions into different files. So I’m sharing how I’ve set it up, as it might help a few people out there.

I’ve divided my actions into several files:

  • authActions.js
  • postActions.js
  • userActions.js

My actions look like this

I then have a actionCreators.js files that export all actions at once.

And then, I can import all actions at once:

But you can also import only the actions needed, of course 😉