0

Is there any way to combine the following:

// This is a React Component
import DataProvider from '../../../src/contexts/Data/DataProvider';
// This is a React Context
import DataContext from '../../../src/contexts/Data/DataContext';
// This is a function
import withDataContext from '../../../src/contexts/Data/withDataContext';

Into something like this:

import Context from 'context';

That allows all to be called as if they were imported individually:

withDataContext(something);
<DataProvider/>

etc.

I have read another answer here ES6 export default with multiple functions referring to each other

But this answer still results in the use of a object to hold all the exported functions.

i.e

Context.withDataContext(something)
Daniel Cooke
  • 1,255
  • 8
  • 20

0 Answers0