router.tsx
import * as React from 'react';
import { Route, HashRouter, Switch } from 'react-router-dom';
import App from './App';
import { LoginContainer } from './containers';
export const AppRouter: React.StatelessComponent<{}> = () => {
return (
<HashRouter>
<div className="container-fluid">
<Route component={App} />
<Switch>
<Route exact path="/" component={LoginContainer} />
<Route path="/login" component={LoginContainer} />
</Switch>
</div>
</HashRouter>
);
}
文件夹结构:
src / containers / index.ts
export * from './auth/LoginContainer';
最后是LoginContainer
import * as React from 'react';
class LoginContainer extends React.Component {
public render() {
return (
<div>
<header>
<h1>This is the Login Container</h1>
</header>
</div>
);
}
}
export default LoginContainer;
答案 0 :(得分:3)
您需要导出默认名称。
export { default as LoginContainer } from './auth/LoginContainer';