I have 5 js files,
I have exported a new component from bar.js with the name NewComponent
then on route.js I re-export with the same name NewComponent,
on other.js NewComponent works fine,
but in dummy.js NewComponent is not defined,
whereas if imported directly from bar.js NewComponent can run normally (see sample.js),
Is there a mistake I made?
/* bar.js */
import { Component } from 'react'
export default class NewComponent extends Component { }
/* route.js */
export { default as NewComponent } from './bar'
/* other.js */
import { NewComponent } from './route'
export default class Other extends Component {
render() {
return (
<NewComponent /> /* work */
)
}
}
/* dummy.js */
import { NewComponent } from './route'
export default class Dummy extends NewComponent { } /* undefined is not an object (evaluating '_bar.default') */
/* sample.js */
import NewComponent from './bar'
export default class Sample extends NewComponent { } /* work */
- UPDATE here is my sample code https://codesandbox.io/s/km5n6o757v