In ES6, is it possible to shorten the following code. I have an App.js
file and an index.js
.
index.js
impo
import App from './App';
export default App;
export { default as App } from './App.js';
Related discussions:
This is a bit of repetition from the previous answers, but to clarify the difference in two options:
1. default export
(This appears to be what OP wants)
export { default } from './App'
// in a different file
import App from './index'
2. named export
export { default as App } from './App'
// in another file
import { App } from './index'
These will work with react
as vsync's answer states.
If you use proposal-export-default-from Babel plugin (which is a part of stage-1 preset), you'll be able to re-export default using the following code:
export default from "./App.js"
For more information see the ECMAScript proposal.
Another way (without this plugin) is:
export { default } from "./App.js"