简体   繁体   English

为什么我在此React / Typescript应用程序中收到no exported member错误?

[英]Why am I getting the no exported member error in this React/Typescript app?

在此输入图像描述

The router.tsx 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>
  );
}

The Folder structure: 文件夹结构:

在此输入图像描述

The src/containers/index.ts src / containers / index.ts

export * from './auth/LoginContainer';

Finally the 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;

You need to export the default as named. 您需要将默认值导出为named。

export { default as LoginContainer } from './auth/LoginContainer';

More: http://jamesknelson.com/re-exporting-es6-modules/ 更多: http//jamesknelson.com/re-exporting-es6-modules/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我收到此错误:声明&#39;<MODULE> &#39; 在本地,但不会导出 - Why I am getting this error: declares '<MODULE>' locally, but it is not exported 为什么我收到未定义的错误错误? - Why am I a getting an error that react is undefined? 为什么我在运行 React 应用程序并单击表单提交时出现此错误 - why i am getting this error while i run react app and click submit in form 打字稿/反应:模块没有导出成员 - Typescript/React: Module has no exported member 为什么收到错误“未捕获的SecurityError:无法在&#39;HTMLCanvasElement&#39;上执行&#39;toDataURL&#39;:错误的画布可能无法导出。 ” - Why am I getting the error “Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. ” firebase.database 不是 function 为什么我在反应本机应用程序中收到此错误? - firebase.database is not a function why I am getting this error in react native app? 我收到此错误:“react-modal:App 元素未定义” - I am getting this error: “react-modal: App element is not defined” 创建新的 React 应用程序时出现错误 - I am getting an error when creating a new react app React JS:为什么我在 componentdidMount() 中出错? - React JS: Why am I getting error at componentdidMount()? 为什么我在 React 中遇到跨源错误? - Why I am getting cross origin error in React?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM