I have split my file containing a large number of functions into multiple files and want to have a common index.js file to export function from each file. How do I do that, using one line of code, or something similar to export * from "./something";
Asked
Active
Viewed 73 times
-1
Vishal Rathore
- 53
- 1
- 4
2 Answers
0
One way to do this would be to create index.js file in the same dir as your functions and then export them like this
export { default as FuncOne } from "./FuncOne";
export { default as FuncTwo } from "./FuncTwo";
export { default as FuncThree } from "./FuncThree";
...
To make sure that this works, each function will need to be exported as default in each file as per the example below.
// FuncOne.js
const FunctOne = () => { ... };
export default FuncOne;
Mantas Astra
- 854
- 6
- 13
-1
no, there is not. old versions usually don't do what the new versions do, it is why they is call new versions
Ernesto
- 3,312
- 1
- 12
- 25