1

Working in ReactJS, I have a number of classes with the same imports:

import MyClass from './some/path/foo.js';
import MyClass2 from './some/path/bar.js';

Only the list is much longer. Can these classes just import one file that has all the imports (bulk import)?

4castle
  • 32,613
  • 11
  • 69
  • 106
dt1000
  • 3,684
  • 6
  • 43
  • 65

1 Answers1

2

I'm assuming you mean you want to have an imports file an then link that file. There is sort of a way to to do this but not sure it gets all of what you need.

You'll create a file imports.js that has:

export * from './some/path/foo.js';
export * from './some/path/bar.js';

then you'll have your file that uses the imports do:

import { MyClass, MyClass2 ... } from './path/to/imports.js';
Paul Ryan
  • 1,509
  • 12
  • 26