I've been having an issue with importing a react class into a container
My file organization is as follows:
├── components
│ ├── Header
│ │ ├── Header.js
│ │ └── index.js
│ └── index.js
├── containers
│ └── HeaderContainer.js
└── index.js
where components/Header/Header.js
exports with
export default class Header extends Component {}
components/Header/index.js
is
import Header from './Header';
import './Header.scss';
export default Header;
and components/index.js
is
export Header from './Header';
and containers/HeaderContainer.js is trying to import with
import { Header } from '../components';
However, this doesn't work, Header is undefined.
If I use import * as components from '../components';
,
Header is listed, but using components.Header
is again undefined.
However, it works perfectly if I instead do
import Header from '../components/Header';
Can anyone explain why the first two methods don't seem to be working? I've done it before this way, and I cannot figure out what I may have changed (admittedly, part of the reason I'm asking is just to type it out a new way and seeing if it helps)
Additionally, I've been able to use
import { Header } from './components';
from an index file in the main directory, which worked perfectly. The issue seems to somehow be with import { Header } from '../components'
only