Reputation: 374
every time I compose react component I make folder for it.
and I make files index.js
and component.jsx
for example
├── App.js
├── component
│ ├── index.js
│ └── Component.jsx
...
index component/index.js
export default from './Component'
actual react component is written in Component.jsx
.
but the problem is when I try to build up app with create-react-app and import Component.jsx
like below
import Component from './component'
error occurs like this
./src/component/index.js
Syntax error: Unexpected token, expected ; (1:20)
> 1 | export default from './Component'
| ^
2 |
but if i write code component/index.js
like this works well.
import Component from './Component'
export default Component
is there any problem with my first index.js
?
Upvotes: 2
Views: 18781
Reputation: 6233
this is the way to re export default import as default export,
export {default} from './Component'
Upvotes: 9