gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 11:13:52 26 4
gpt4 key购买 nike

enter image description here

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>
);
}

文件夹结构:

enter image description here

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;

最佳答案

您需要将默认导出为命名。

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

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

关于javascript - 为什么我在这个 React/Typescript 应用程序中收到 no exported member 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52460953/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com