1

I have redux actions which are small simple function in many files. I then combine them in a single file as below. This file is named moduleActions.js

import * as actions1 from './someActions';
import * as actions2 from './moreActions';
import * as actions3 from './someMoreActions';

const moduleActions = Object.assign({}, actions1, actions2, actions3);

export default moduleActions

How do I export moduleActions without the default? The code above works but my functions coming from actions1, actions2, etc are inside the default object -- see below:

{
   default: {
     function1(),
     function2()
   }
}

I don't want the default object in there. My functions should be in the main object:

{
   function1(),
   function2()
}

I tried exporting moduleActions without the default but that gives me an error.

UPDATE: Solution seems to be exporting them directly without even trying to combine them. So my moduleActions.js file now looks like this:

export * from './someActions';
export * from './moreActions';
export * from './someMoreActions';
Sam
  • 26,817
  • 58
  • 206
  • 383
  • Possible duplicate of [ES6 export all values from object](http://stackoverflow.com/questions/29844074/es6-export-all-values-from-object) – Andy Ray Dec 27 '16 at 00:33
  • I don't see how it's a duplicate – Sam Dec 27 '16 at 00:36
  • So you'd like to remove the `default` property from the object? The reason the answer above was linked is because normally you'd re-export the actions directly with `export * from './someActions';`, then `import * as actions from './moduleActions';` with no `Object.assign` stuff anywhere, and the imported `actions` object would have everything you currently get, without the `.default` – loganfsmyth Dec 27 '16 at 00:47
  • Do you mean after importing actions from individual files, I'd to an export for each set of actions in the myModules.js file? In other words, using my example, I'd have 3 exports in my moduleActions.js file? – Sam Dec 27 '16 at 00:50
  • I think I see what you mean now. I just tried export * from 'someActions'; etc. and it worked fine. So, we're exporting directly without trying to combine anything. – Sam Dec 27 '16 at 00:53

0 Answers0